-3
我想在我的android應用程序中使用sqlite備份我的數據庫。由於這是谷歌給定的代碼,但它沒有顯示任何結果,甚至在logcat中出現錯誤。它應該是什麼意思?對不起我只是新的Android開發..Android備份數據庫沒有結果
try {
File sd = Environment.getDataDirectory();
File data = Environment.getDataDirectory();
FileChannel source=null;
FileChannel destination=null;
if (sd.canWrite()) {
String currentDBPath = "//data//" + "com.example.jes.myapplication"
+ "//databases//" + "TINDERO.DB";
String backupDBPath = "//data//" + "com.example.jes.myapplication"
+ "//databases//" + "//TINDERO_BACKUP//" + "TINDERO.DB";
File currentDB = new File(data, currentDBPath);
File backupDB = new File(sd, backupDBPath);
FileChannel src = new FileInputStream(currentDB).getChannel();
FileChannel dst = new FileOutputStream(backupDB).getChannel();
dst.transferFrom(src, 0, src.size());
src.close();
dst.close();
Toast.makeText(getApplicationContext(), "Backup Successful!",
Toast.LENGTH_SHORT).show();
Toast.makeText(getApplicationContext(), "Hello", Toast.LENGTH_SHORT).show();
}
} catch (IOException e) {
Toast.makeText(getApplicationContext(), "Failed",Toast.LENGTH_SHORT).show();
}
}
});
介意將**完整的logcat **添加到您的問題中? –