我需要查看我的android設備中的數據庫,但由於它是一個根目錄設備,我無法這樣做。我在我的DBAdapter類中實現了以下代碼,並在其他活動中調用它。如何查看Android設備中的數據庫?
CODE:
void exportDB() {
try {
File sd = Environment.getExternalStorageDirectory();
File data = Environment.getDataDirectory();
if (sd.canWrite()) {
String currentDBPath = "//data//" + "com.example.facebook_integration"
+ "//databases//" + "image_database.db";
String backupDBPath = "//sdcard//FBDatabase";
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();
}
} catch (Exception e) {
//Toast.makeText(getApplicationContext(), "Backup Failed!", Toast.LENGTH_SHORT).show();
}
}
但上面的代碼似乎並沒有工作。我已經在Stackoverflow中很好地瞭解了這個問題(有一些安靜),並且嘗試了adb命令,但沒有一個能夠工作。你能告訴我上面的代碼出錯了嗎?還是上述解決方案的替代方案?幫助將不勝感激的傢伙。
我在查看文件資源管理器中的SDCard內容時有另一個疑問。我無法查看DDMS Filexplorer中的SD卡內容。我只需要檢索數據庫以在SQLiteBrowser中查看它。我該怎麼做 ? – San