i have a default.realm file in my "assets/default.realm" folder, I am not able to make it as a default realm database
realm.getDefaultInstance();
src= new File("assets/default.realm");
dst=new File("/data/data/" + context.getPackageName() + "/files/");
if (!(realm.isEmpty())) {
Log.v("DB","already there!!");
} else {
try {
copyFile(src,dst);
} catch (IOException e) {
Log.v("DB","Wrong Path!");
}
}
void copyFile(File src, File dst) throws IOException {
FileChannel inChannel = new FileInputStream(src).getChannel();
FileChannel outChannel = new FileOutputStream(dst).getChannel();
try {
inChannel.transferTo(0, inChannel.size(), outChannel);
} finally {
if (inChannel != null)
inChannel.close();
if (outChannel != null)
outChannel.close();
}
}
but failed to copy please help
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…