2

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.

Community
  • 1
  • 1
EGHDK
  • 17,818
  • 45
  • 129
  • 204
  • Can you post the error and the logcat? – prprcupofcoffee Nov 13 '12 at 14:23
  • There is no error. I should be getting a database from the phone, and moving it to SD card. I transfer the file (it gets created) from the phone to the computer but it doesn't work. Unlike the database file from the emulator. – EGHDK Nov 13 '12 at 14:25
  • I'm able to get the code above to "work" as in, it creates the file called "test4" in the root. I move the file over to my computer and try to view it with a sql browser, but it doesn't open it like my database files from the emulator. The code above seems to be creating an empty file. – EGHDK Nov 13 '12 at 14:43

0 Answers0