2012-04-23 29 views

回答

1

「currentDBPath」包含DB的路徑。您可以將其作爲文件複製並使用以下步驟將其保存在其他位置。

String currentDBPath = "/data/"+getApplicationInfo().packageName+"/databases/db_name"; 

FileChannel src = new FileInputStream(currentDB).getChannel(); // source 
FileChannel dst = new FileOutputStream(backupDB).getChannel(); // destination 
dst.transferFrom(src, 0, src.size()); // to copy from source to destination 
src.close(); 
dst.close(); 

希望這是你在找什麼。

+0

不應該是'「/ data/data/....」'? – waqaslam 2012-04-23 09:24:37

+1

'文件srcFile = getDatabasePath(「db_name」);' – zapl 2012-04-23 09:31:27

+0

@Waqas不,這適用於我...我在我的應用程序中使用它。 – Pallavi 2012-04-23 09:43:52

相關問題