
把assets的数据拷贝到手机 data/data/包名xxx下
private void copyDB(String path) {
// 判断只要拷贝一次就不要再拷贝
try {
InputStream is = getAssets().open(path);
File file = new File(getFilesDir(), path);
if(file.exists()&&file.length()>0){
//正常 不需要拷贝 了
Log.i("select","不需要拷贝");
}else{
FileOutputStream fos = new FileOutputStream(file);
byte[] buffer = new byte[1024];
int len = 0;
while((len=is.read(buffer))!=-1){
fos.write(buffer,0,len);
}
is.close();
fos.close();
}
} catch (IOException e) {
e.printStackTrace();
}
}