Skip to content Skip to sidebar Skip to footer

Sqlitecantopendatabaseexception: Unknown Error (code 14) Could Not Open Database

I'm getting this error when I'm trying to get a readable or writable database. 'SQLiteCantOpenDatabaseException: unknown error (code 14) Could not open database' I'm having this we

Solution 1:

You are using SQLiteDatabase.openDatabase on a file path that may not exist. Add below 2 lines just before SQLiteDatabase.openDatabase call

privatebooleancheckDataBase() {
    SQLiteDatabasecheckDB=null;
    try {

        StringmyPath= DB_PATH + DB_NAME;

        Filefile=newFile(myPath);
        if (file.exists() && !file.isDirectory())
        checkDB = SQLiteDatabase.openDatabase(myPath, null, SQLiteDatabase.OPEN_READWRITE);
    } catch (SQLiteException e) {
        // database does't exist yet.
    }

    if (checkDB != null) {
        checkDB.close();
    }

    return checkDB != null ? true : false;
}

Solution 2:

Error stopped to show after I changed the targetSdkVersion from 23 to 22. This downgrade forced to uninstall the package at the device and when It was reinstalled it worked fine. Thank you Frank N. Stein for the help!

Post a Comment for "Sqlitecantopendatabaseexception: Unknown Error (code 14) Could Not Open Database"