Possible Duplicate:
Moving my db to sd card not working
I get a file on the root of my sdcard called test4, but when I move it to my computer with a sqlite browser it doesn't work. Any ideas?
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 says the file is "20.0 KB". The database file coming from my emulator has a ton of more entries in it, but the file is only "9.00 KB". I have created multiple files "test1", "test2", "test3", "test4", but they all come out the same exact size. Is my database not "copyable" by any chance? I don't know how to find out. Astro file manager has files details. When I see the details about this file. It gives me the size and that the permissions are "-rw", don't know if that helps.