자산 폴더에서 DB로 DB를 복사하려고합니다. 이 코드는 에뮬레이터와 루팅 된 장치에서 잘 작동합니다. 난 그냥 그것이 unrooted 장치에 어떤 문제를 만들거나 똑같이 작동합니다 알고 싶습니다.루팅되지 않은 장치의 자산 폴더에서 데이터베이스 복사
private void StoreDatabase() {
File DbFile = new File(
"data/data/packagename/DBname.sqlite");
if (DbFile.exists()) {
System.out.println("file already exist ,No need to Create");
} else {
try {
DbFile.createNewFile();
System.out.println("File Created successfully");
InputStream is = this.getAssets().open("DBname.sqlite");
FileOutputStream fos = new FileOutputStream(DbFile);
byte[] buffer = new byte[1024];
int length = 0;
while ((length = is.read(buffer)) > 0) {
fos.write(buffer, 0, length);
}
System.out.println("File succesfully placed on sdcard");
// Close the streams
fos.flush();
fos.close();
is.close();
} catch (IOException e) {
e.printStackTrace();
}
}
}
예 당신의 코드가 루팅 해제 장치에서 완벽하게 작동도 : –