Deleting database and restart application


#1

Hi,

I have a certain scenario where everything is deleted and the app restarts.

I do this with the following:

final File databasePath = getActivity().getDatabasePath(XXXXDbHelper.DATABASE_NAME);
databasePath.delete();

After this I restart the app with ProcessPhoenix

 ProcessPhoenix.triggerRebirth(getActivity());

When the app restarts I get the following errors:

11-27 11:56:34.334 3718-3718/? I/Database: sqlite returned: error code = 26, msg = file is encrypted or is not a database
11-27 11:33:28.634 16373-16373/? E/Database: CREATE TABLE android_metadata failed
11-27 11:33:28.634 16373-16373/? E/Database: Failed to setLocale() when constructing, closing the database
                                         net.sqlcipher.database.SQLiteException: file is encrypted or is not a database
                                             at net.sqlcipher.database.SQLiteDatabase.native_setLocale(Native Method)

&

11-27 11:33:28.634 16373-16373/? E/SQLiteOpenHelper: Couldn't open XXXXX.db for writing (will try read-only):
                                                 net.sqlcipher.database.SQLiteException: file is encrypted or is not a database
                                                     at net.sqlcipher.database.SQLiteDatabase.native_setLocale(Native Method)

What is the problem here? The database file should be deleted synchronously and the application should create a new database, since there is none (like at initial start up.)


#2

I’ve narrowed down the problem as follows:

After deletion of the database, and restarting the application with ProcessPhoenix. The onCreate of the dbHelper is not called and in extension to that there is no new database to work with. I’ve looked everywhere but I cannot find anything to prevent or force recreation of the database when it should be deleted.


#3

The call to onCreate will only occur once you have called getWriteableDatabase(), is your application doing that?