SQLiteAssetHelper - problems on specific phones, e.g. OnePlus

I'm experiencing crashes on some devices when using SQLiteAssetHelper in my app, most of all on OnePlus devices. Now I read here that it has to do with the directory the database is stored.

Now I'm trying to find a workaround, the best I could come up with currently is a constructor like this

public MySubclass(Context context) {
    super(context, databaseName, context.getFilesDir() + "/databases", null, databaseVersion);

Is this the correct way to do it or are there other problems with this approach?


The exception is

Fatal Exception: android.database.sqlite.SQLiteException: Can't upgrade read-only database from version x to y: /data/data/my.package.id/databases/database.db

Sorry, I linked the wrong SO-question: this is the correct one. There it says 'OnePlus is able to copy the database to /data/data/package-name/databases/filename.db but it doesn't allow to access that data and i have no clue regarding that.'


The SQLiteAssetHelper constructor allows you to specify your own database destination path (the folder needs to be writable). If you don't specify any it is using one by default. See this excerpt from the Github repo:

    if (storageDirectory != null) {
        mDatabasePath = storageDirectory;
    } else {
        mDatabasePath = context.getApplicationInfo().dataDir + "/databases";

Hey you can copy database from one to another from below mentioned code.

public class MySQLiteHelper extends SQLiteOpenHelper implements DBConstants {

private static MySQLiteHelper mInstance = null;
private SQLiteDatabase myDataBase;
private static String DB_PATH = "";

public MySQLiteHelper(Context context) {
    super(context, DATABASE_NAME, null, DATABASE_VERSION);
    try {
        if (checkDataBase())
            myDataBase = this.getReadableDatabase();
    } catch (Exception e) {

public static MySQLiteHelper instance(Context context) {

    File outFile = context.getDatabasePath(DATABASE_NAME);
    DB_PATH = outFile.getPath();

    if (mInstance == null) {
        mInstance = new MySQLiteHelper(context);

    return mInstance;

Need Your Help

Having trouble with mapbox GL layers

javascript mapbox-gl mapbox-gl-js

So, I'm trying to get a style layer from the loaded stylemap in mapbox GL but it keeps returning undefined elements. I'm at the end of my wits.

WCF: Cache SSL data

c# wcf security ssl wcf-security

I want to create WCF service and client. I want to add 2 way SSL between these 2 services.