重複の可能性:
データベースをSDカードに移動できない
SD カードのルートに test4 というファイルを取得しましたが、それを sqlite ブラウザーを使用してコンピューターに移動すると、機能しません。何か案は?
File data = Environment.getDataDirectory();
File sd = Environment.getExternalStorageDirectory();
if (sd.canWrite()) {
String currentDBPath = "/data/com.test.this/databases/this_db";
String backupDBPath = "/test4";
File currentDB = new File(data, currentDBPath);
File backupDB = new File(sd, backupDBPath);
if (currentDB.exists()) {
FileChannel src;
try {
src = new FileInputStream(currentDB).getChannel();
FileChannel dst = new FileOutputStream(backupDB)
.getChannel();
try {
dst.transferFrom(src, 0, src.size());
src.close();
dst.close();
} catch (IOException e) {
e.printStackTrace();
}
} catch (FileNotFoundException e) {
e.printStackTrace();
}
}
}
Windows は、ファイルが「20.0 KB」であると言います。エミュレーターからのデータベース ファイルにはさらに多くのエントリがありますが、ファイルは「9.00 KB」しかありません。複数のファイル「test1」、「test2」、「test3」、「test4」を作成しましたが、すべて同じ正確なサイズになります。私のデータベースは「コピー可能」ではありませんか? 調べる方法がわかりません。アストロ ファイル マネージャーには、ファイルの詳細があります。このファイルの詳細を見ると。サイズと権限が「-rw」であることがわかりますが、それが役立つかどうかはわかりません。