Jearil/SimpleNoSQL

Failed to change locale for db

hiasel opened this issue · 0 comments

Today I've received the following crash when the app tried to delete some entities. It's the first time I am receiving this error, I did not change anything in the calling code.

Fatal Exception: android.database.sqlite.SQLiteException
Failed to change locale for db '/data/user/0/com.my.app/databases/simplenosql.db' to 'en_US'.

As far as I understand https://stackoverflow.com/a/19491862/2350644 might fix the issue.
I.e. in SimpleNoSQLDBHelper.java change the constuctor call from this:

public SimpleNoSQLDBHelper(Context context, DataSerializer serializer, DataDeserializer deserializer) {
        super(context, DATABASE_NAME, null, DATABASE_VERSION);
        this.serializer = serializer;
        this.deserializer = deserializer;
    }

to this:

public SimpleNoSQLDBHelper(Context context, DataSerializer serializer, DataDeserializer deserializer) {
        super(context, DATABASE_NAME, null, DATABASE_VERSION, SQLiteDatabase.NO_LOCALIZED_COLLATORS | SQLiteDatabase.OPEN_READWRITE);
        this.serializer = serializer;
        this.deserializer = deserializer;
    }

I wasn't yet able to reproduce this error and test if this really works. I will answer to this post (and possibly create a PR) if it solves the error.

Here is the detailed stack trace:

Fatal Exception: android.database.sqlite.SQLiteException
Failed to change locale for db '/data/user/0/com.my.app/databases/simplenosql.db' to 'en_US'.
android.database.sqlite.SQLiteConnection.setLocaleFromConfiguration (SQLiteConnection.java:567)
android.database.sqlite.SQLiteConnection.open (SQLiteConnection.java:305)
android.database.sqlite.SQLiteConnection.open (SQLiteConnection.java:215)
android.database.sqlite.SQLiteConnectionPool.openConnectionLocked (SQLiteConnectionPool.java:705)
android.database.sqlite.SQLiteConnectionPool.open (SQLiteConnectionPool.java:272)
android.database.sqlite.SQLiteConnectionPool.open (SQLiteConnectionPool.java:239)
android.database.sqlite.SQLiteDatabase.openInner (SQLiteDatabase.java:1292)
android.database.sqlite.SQLiteDatabase.open (SQLiteDatabase.java:1247)
android.database.sqlite.SQLiteDatabase.openDatabase (SQLiteDatabase.java:903)
android.database.sqlite.SQLiteDatabase.openDatabase (SQLiteDatabase.java:893)
android.database.sqlite.SQLiteOpenHelper.getDatabaseLocked (SQLiteOpenHelper.java:355)
android.database.sqlite.SQLiteOpenHelper.getWritableDatabase (SQLiteOpenHelper.java:298)
com.colintmiller.simplenosql.db.SimpleNoSQLDBHelper.deleteEntity (SimpleNoSQLDBHelper.java:75)
com.colintmiller.simplenosql.threading.DataDispatcher.delete (DataDispatcher.java:106)
com.colintmiller.simplenosql.threading.DataDispatcher.run (DataDispatcher.java:80)