I'm attempting to back up a version of my database on dropbox. Everything works fine uploading the file to dropbox but I'm having trouble replacing the one that is currently on the phone with the one on dropbox.
new Thread(new Runnable() {
public void run() {
File file = new File(getDatabasePath("my_database").getPath());
file.getParentFile().mkdirs();
try {
FileOutputStream outputStream = new FileOutputStream(file);
DropboxFileInfo info =dbInstance.getFile("/BackupFolder/my_database", null,
outputStream, null);
} catch (Exception ex) {
ex.printStackTrace();
}
}
}).start();
When the operation completes I get a lot of "SQLiteException: no such table" errors after this. I have verified that the database in dropbox is correct.
01-09 20:03:37.601: W/System.err(7185): android.database.sqlite.SQLiteException: no such table: transaction_table (code 1)
at android.database.sqlite.SQLiteConnection.nativeExecuteForCursorWindow(Native Method)
01-09 20:03:37.601: W/System.err(7185): at android.database.sqlite.SQLiteConnection.executeForCursorWindow(SQLiteConnection.java:1036)
01-09 20:03:37.601: W/System.err(7185): at android.database.sqlite.SQLiteSession.executeForCursorWindow(SQLiteSession.java:836)
01-09 20:03:37.601: W/System.err(7185): at android.database.sqlite.SQLiteQuery.fillWindow(SQLiteQuery.java:62)
01-09 20:03:37.601: W/System.err(7185): at android.database.sqlite.SQLiteCursor.fillWindow(SQLiteCursor.java:144)
01-09 20:03:37.601: W/System.err(7185): at android.database.sqlite.SQLiteCursor.getCount(SQLiteCursor.java:133)
01-09 20:03:37.601: W/System.err(7185): at android.content.ContentResolver.query(ContentResolver.java:436)
01-09 20:03:37.601: W/System.err(7185): at android.content.ContentResolver.query(ContentResolver.java:360)
UPDATE
I've downloaded the file to another location on the device so that I can view it using sqlite3 and everything is in there. So, apparently the download is working correctly but I'm not able to overwrite the existing database at runtime with this file.