我的问题如下: 我已经在本地SD上正确移动了SQlite数据库,但是通过USB连接从设备和PC都看不到该文件。 该应用程序不会引发任何错误。 以下是执行复制的方法: private void exportDB(){
DBHelper db = DBHelper.getInstance(this);
String DBName = db.getDBName();
File dbPath = this.getDatabasePath(DBName);
String DBPath = dbPath.getAbsolutePath();
//Toast.makeText(this, "DB Path : " + DBPath , Toast.LENGTH_LONG).show();
File sd = Environment.getExternalStorageDirectory();
File data = Environment.getDataDirectory();
FileChannel source=null;
FileChannel destination=null;
String currentDBPath = DBPath;
String backupDBPath = "Download/"+DBName;
File currentDB = new File(currentDBPath);
File backupDB = new File(sd, backupDBPath);
try {
source = new FileInputStream(currentDB).getChannel();
destination = new FileOutputStream(backupDB).getChannel();
destination.transferFrom(source, 0, source.size());
source.close();
destination.close();
Toast.makeText(this, "DB Exported!", Toast.LENGTH_LONG).show();
} catch(FileNotFoundException e) {
e.printStackTrace();
}catch(IOException e) {
e.printStackTrace();
}
}
答案 0 :(得分:0)
对于转移DB,我认为它可以在root设备中实现。