我在应用程序中使用Sql数据库, 我想获取数据库的备份。 我存有以下疑问:
1.I am running the application in emulator,for checking whether i have to plug some external storage to check ,if not in my system how can i check. 2.I am using the following code in my application,in that sdcard.write option is showing false,what wrong in this.
福林是我的代码:
try {
File sd = Environment.getExternalStorageDirectory();
File data = Environment.getDataDirectory();
java.lang.System.out.println("data="+sd.getAbsolutePath());
java.lang.System.out.println("data="+sd.canWrite());--->Showing as false
if (sd.canWrite()) {
String currentDBPath = "\data\com.budget\databases\budget";
String backupDBPath = "budget";
File currentDB = new File(data, currentDBPath);
File backupDB = new File(sd, backupDBPath);
java.lang.System.out.println("backup="+backupDB.getAbsolutePath());
if (currentDB.exists()) {
FileChannel src = new FileInputStream(currentDB).getChannel();
FileChannel dst = new FileOutputStream(backupDB).getChannel();
dst.transferFrom(src, 0, src.size());
src.close();
dst.close();
}
}
} catch (Exception e) {
}