Sqlite Database suddenly closed on devices using MDM in Native Android app

191 Views Asked by At

Our android application is used by thousands of user and has been live for the past four years. The app stores hundreds of thousands of rows where on a daily basis thousands are inserted, updated and removed in a number different tables. We are using SQLCipher - Zetetic. Recently one of our clients started facing an issue with an MDM(SOTI) software they are using on their device Samsung J3. On MDM enabled devices, sometime the database is closing or being corrupted while performing a database operation with following exception:

Caused by net.sqlcipher.database.SQLiteException no such table: customer_record: , while compiling: SELECT record_id, record_branch_id, record_customer_id, status, description, start_date FROM customer_record WHERE is_synchronized=?

This is not always reproducible but once it occurs, from then on, the database cannot be opened by the app, even though it exists on the phone's storage. We've managed to extract the database from an affected device and observed that the table customer_record table is present in database.

Could this be caused due to MDM restricting the access to the file? If yes - the question is, why is it not consistently reproducing?

Update

In onUpgrade() method we apply the database/schema changes that are included in the current version as compared to the earlier versions in following fashion

  public void onUpgrade(SQLiteDatabase pDb, int pOldVersion, int pNewVersion) {
      switch (pOldVersion) {
        case 5:// when moving from version 5 onward
          dbVersion5(pDb);
        case 6:// when moving from version 6 onward
          dbVersion5(pDb);    
        }

}

Where dbVersionX() method runs the alter table / add table commands.

0

There are 0 best solutions below