SQLite Forum

Timeline
Login

5 forum posts by user BlackGB

2021-09-19
09:35 Reply: sqlite-android-3360000.aar / SQLiteOpenHelper / getWritableDatabase() / unknown error (code 14): Could not open database (artifact: 39e42eb76a user: BlackGB)

Oh ok i understood, on the build there are not the DEBUG_STRICT_READONLY part (i forgot that the compiler removes unused code) but your modification seems OK.

so, a big thanks @dan, you are a chief.

2021-09-18
19:08 Edit reply: sqlite-android-3360000.aar / SQLiteOpenHelper / getWritableDatabase() / unknown error (code 14): Could not open database (artifact: 4a5045ad4b user: BlackGB)

Oh nice yes theses codes seem be better.

But i did't build my version and just took the online build here : https://sqlite.org/download.html the Precompiled Binaries for Android: https://sqlite.org/2021/sqlite-android-3360000.aar

and this version have neither the code before nor the code after the support for file://

so maybe the next build/packaging could be good on the good branch ;) ?

19:00 Reply: sqlite-android-3360000.aar / SQLiteOpenHelper / getWritableDatabase() / unknown error (code 14): Could not open database (artifact: d4ecfc8b79 user: BlackGB)

Oh nice yes theses codes seem be better.

But i did't build my version and just take the online build here : https://sqlite.org/download.html the Precompiled Binaries for Android: https://sqlite.org/2021/sqlite-android-3360000.aar

and this version have neither the code before nor the code after the support for file://

so maybe the next build could be good ?

12:27 Edit: sqlite-android-3360000.aar / SQLiteOpenHelper / getWritableDatabase() / unknown error (code 14): Could not open database (artifact: e1a344f257 user: BlackGB)

keywords: sqlite-android-3360000.aar / SQLiteOpenHelper / getWritableDatabase() / unknown error (code 14): Could not open database

Hi, Something seems strong in the new SQLiteOpenHelper class of the sqlite-android-3360000.aar build. I want to use that version because the default SDK version don't support RTREE compilation option.

Here is a part of my main Activity code to testing : try { System.loadLibrary("sqliteX");

AppDB appDB = new AppDB(getApplicationContext());

Log.d("MainActivity", appDB.getDatabaseName());
Log.d("MainActivity",this.getDatabasePath(appDB.getDatabaseName()).toString());
Log.d("MainActivity",getApplicationContext().getDatabasePath(appDB.getDatabaseName()).toString());

SQLiteDatabase _bdd = appDB.getWritableDatabase();
Log.d("MainActivity", _bdd.toString());

} catch (Exception e) { Log.e("MainActivity", e.toString()); }

First try with default SqlLite library and who work fine: import android.database.sqlite.SQLiteDatabase; import android.database.sqlite.SQLiteOpenHelper; //import org.sqlite.database.sqlite.SQLiteDatabase; //import org.sqlite.database.sqlite.SQLiteOpenHelper;

public class AppDB extends SQLiteOpenHelper {

public static final int DATABASE_VERSION = 1;
public static final String DATABASE_NAME = "MyBuoy.db3";

public AppDB(Context context) {
    super(context, DATABASE_NAME, null, DATABASE_VERSION);
    //super(context, context.getDatabasePath(DATABASE_NAME).getPath(), null, DATABASE_VERSION);
}

../..

} The Logs are : 2021-09-18 13:22:04.058 29266-29266/com.gb.mybuoy D/MainActivity: MyBuoy.db3 2021-09-18 13:22:04.059 29266-29266/com.gb.mybuoy D/MainActivity: /data/user/0/com.gb.mybuoy/databases/MyBuoy.db3 2021-09-18 13:22:04.066 29266-29266/com.gb.mybuoy D/MainActivity: /data/user/0/com.gb.mybuoy/databases/MyBuoy.db3 2021-09-18 13:22:09.878 29266-29266/com.gb.mybuoy D/MainActivity: SQLiteDatabase: /data/user/0/com.gb.mybuoy/databases/MyBuoy.db3

Second try with sqlite-android-3360000.aar build and failed with unknown error (code 14): Could not open database: //import android.database.sqlite.SQLiteDatabase; //import android.database.sqlite.SQLiteOpenHelper; import org.sqlite.database.sqlite.SQLiteDatabase; import org.sqlite.database.sqlite.SQLiteOpenHelper;

public class AppDB extends SQLiteOpenHelper {

public static final int DATABASE_VERSION = 1;
public static final String DATABASE_NAME = "MyBuoy.db3";

public AppDB(Context context) {
    super(context, DATABASE_NAME, null, DATABASE_VERSION);
    //super(context, context.getDatabasePath(DATABASE_NAME).getPath(), null, DATABASE_VERSION);
}

../..

} The Logs are : 2021-09-18 13:25:01.226 29518-29518/com.gb.mybuoy D/MainActivity: MyBuoy.db3 2021-09-18 13:25:01.227 29518-29518/com.gb.mybuoy D/MainActivity: /data/user/0/com.gb.mybuoy/databases/MyBuoy.db3 2021-09-18 13:25:01.228 29518-29518/com.gb.mybuoy D/MainActivity: /data/user/0/com.gb.mybuoy/databases/MyBuoy.db3 2021-09-18 13:25:22.772 29518-29518/com.gb.mybuoy E/SQLiteDatabase: Failed to open database 'MyBuoy.db3'. org.sqlite.database.sqlite.SQLiteCantOpenDatabaseException: unknown error (code 14): Could not open database at org.sqlite.database.sqlite.SQLiteConnection.nativeOpen(Native Method) at org.sqlite.database.sqlite.SQLiteConnection.open(SQLiteConnection.java:214) at org.sqlite.database.sqlite.SQLiteConnection.open(SQLiteConnection.java:198) at org.sqlite.database.sqlite.SQLiteConnectionPool.openConnectionLocked(SQLiteConnectionPool.java:466) at org.sqlite.database.sqlite.SQLiteConnectionPool.open(SQLiteConnectionPool.java:188) at org.sqlite.database.sqlite.SQLiteConnectionPool.open(SQLiteConnectionPool.java:180) at org.sqlite.database.sqlite.SQLiteDatabase.openInner(SQLiteDatabase.java:810) at org.sqlite.database.sqlite.SQLiteDatabase.open(SQLiteDatabase.java:795) at org.sqlite.database.sqlite.SQLiteDatabase.openDatabase(SQLiteDatabase.java:698) at org.sqlite.database.sqlite.SQLiteDatabase.openOrCreateDatabase(SQLiteDatabase.java:721) at org.sqlite.database.sqlite.SQLiteOpenHelper.getDatabaseLocked(SQLiteOpenHelper.java:259) at org.sqlite.database.sqlite.SQLiteOpenHelper.getWritableDatabase(SQLiteOpenHelper.java:199) at com.gb.mybuoy.MainActivity.onRequestPermissionsResult(MainActivity.java:122) at android.app.Activity.dispatchRequestPermissionsResult(Activity.java:7608) at android.app.Activity.dispatchActivityResult(Activity.java:7458) at android.app.ActivityThread.deliverResults(ActivityThread.java:4353) at android.app.ActivityThread.handleSendResult(ActivityThread.java:4402) at android.app.servertransaction.ActivityResultItem.execute(ActivityResultItem.java:49) at android.app.servertransaction.TransactionExecutor.executeCallbacks(TransactionExecutor.java:108) at android.app.servertransaction.TransactionExecutor.execute(TransactionExecutor.java:68) at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1808) at android.os.Handler.dispatchMessage(Handler.java:106) at android.os.Looper.loop(Looper.java:193) at android.app.ActivityThread.main(ActivityThread.java:6669) at java.lang.reflect.Method.invoke(Native Method) at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:493) at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:858) 2021-09-18 13:25:25.203 29518-29518/com.gb.mybuoy E/MainActivity: org.sqlite.database.sqlite.SQLiteCantOpenDatabaseException: unknown error (code 14): Could not open database

and Third try with sqlite-android-3360000.aar build and full path database who work fine: //import android.database.sqlite.SQLiteDatabase; //import android.database.sqlite.SQLiteOpenHelper; import org.sqlite.database.sqlite.SQLiteDatabase; import org.sqlite.database.sqlite.SQLiteOpenHelper;

public class AppDB extends SQLiteOpenHelper {

public static final int DATABASE_VERSION = 1;
public static final String DATABASE_NAME = "MyBuoy.db3";

public AppDB(Context context) {
    //super(context, DATABASE_NAME, null, DATABASE_VERSION);
    super(context, context.getDatabasePath(DATABASE_NAME).getPath(), null, DATABASE_VERSION);
}

../..

} The Logs are : 2021-09-18 13:28:33.176 29884-29884/com.gb.mybuoy D/MainActivity: /data/user/0/com.gb.mybuoy/databases/MyBuoy.db3 2021-09-18 13:28:33.178 29884-29884/com.gb.mybuoy D/MainActivity: /data/user/0/com.gb.mybuoy/databases/MyBuoy.db3 2021-09-18 13:28:41.829 29884-29884/com.gb.mybuoy D/MainActivity: SQLiteDatabase: /data/user/0/com.gb.mybuoy/databases/MyBuoy.db3

So i investigated and this part of the code seems wrong : In file SQLiteOpenHelper.class private SQLiteDatabase getDatabaseLocked(boolean writable) { ../..

try {
    db = SQLiteDatabase.openOrCreateDatabase(this.mName, this.mFactory, this.mErrorHandler);
} catch (SQLiteException var15) {
    if (writable) {
        throw var15;
    }

    Log.e(TAG, "Couldn't open " + this.mName + " for writing (will try read-only):", var15);
    String path = this.mContext.getDatabasePath(this.mName).getPath();
    db = SQLiteDatabase.openDatabase(path, this.mFactory, 1, this.mErrorHandler);
}


../..

} Why in the catch case there are a try with this.mContext.getDatabasePath(this.mName) path only in the not writable case ? Why in the default case this.mContext.getDatabasePath is not called ? Why i have to call supper class method like super(context, context.getDatabasePath(DATABASE_NAME).getPath(), null, DATABASE_VERSION) and pass to the second argument the full path base on the context then the context is in the first argument for that work done ?

The seems strange and seems wrong in that version of SQLiteOpenHelper ?!

11:36 Post: sqlite-android-3360000.aar / SQLiteOpenHelper / getWritableDatabase() / unknown error (code 14): Could not open database (artifact: 38ef6235f9 user: BlackGB)

keywords: sqlite-android-3360000.aar / SQLiteOpenHelper / getWritableDatabase() / unknown error (code 14): Could not open database

Hi, Something seems strong in the new SQLiteOpenHelper class of the sqlite-android-3360000.aar build. I want to use that version because the default SDK version don't support RTREE compilation option.

Here is a part of my main Activity code to testing : try { System.loadLibrary("sqliteX");

AppDB appDB = new AppDB(getApplicationContext());

Log.d("MainActivity", appDB.getDatabaseName());
Log.d("MainActivity",this.getDatabasePath(appDB.getDatabaseName()).toString());
Log.d("MainActivity",getApplicationContext().getDatabasePath(appDB.getDatabaseName()).toString());

SQLiteDatabase _bdd = appDB.getWritableDatabase();
Log.d("MainActivity", _bdd.toString());

} catch (Exception e) { Log.e("MainActivity", e.toString()); }

First try with default SqlLite library and who work fine: import android.database.sqlite.SQLiteDatabase; import android.database.sqlite.SQLiteOpenHelper; //import org.sqlite.database.sqlite.SQLiteDatabase; //import org.sqlite.database.sqlite.SQLiteOpenHelper;

public class AppDB extends SQLiteOpenHelper {

public static final int DATABASE_VERSION = 1;
public static final String DATABASE_NAME = "MyBuoy.db3";

public AppDB(Context context) {
    super(context, DATABASE_NAME, null, DATABASE_VERSION);
    //super(context, context.getDatabasePath(DATABASE_NAME).getPath(), null, DATABASE_VERSION);
}

../..

}

The Logs are : 2021-09-18 13:22:04.058 29266-29266/com.gb.mybuoy D/MainActivity: MyBuoy.db3 2021-09-18 13:22:04.059 29266-29266/com.gb.mybuoy D/MainActivity: /data/user/0/com.gb.mybuoy/databases/MyBuoy.db3 2021-09-18 13:22:04.066 29266-29266/com.gb.mybuoy D/MainActivity: /data/user/0/com.gb.mybuoy/databases/MyBuoy.db3 2021-09-18 13:22:09.878 29266-29266/com.gb.mybuoy D/MainActivity: SQLiteDatabase: /data/user/0/com.gb.mybuoy/databases/MyBuoy.db3

Second try with sqlite-android-3360000.aar build and failed with unknown error (code 14): Could not open database: //import android.database.sqlite.SQLiteDatabase; //import android.database.sqlite.SQLiteOpenHelper; import org.sqlite.database.sqlite.SQLiteDatabase; import org.sqlite.database.sqlite.SQLiteOpenHelper;

public class AppDB extends SQLiteOpenHelper {

public static final int DATABASE_VERSION = 1;
public static final String DATABASE_NAME = "MyBuoy.db3";

public AppDB(Context context) {
    super(context, DATABASE_NAME, null, DATABASE_VERSION);
    //super(context, context.getDatabasePath(DATABASE_NAME).getPath(), null, DATABASE_VERSION);
}

../..

}

The Logs are : 2021-09-18 13:25:01.226 29518-29518/com.gb.mybuoy D/MainActivity: MyBuoy.db3 2021-09-18 13:25:01.227 29518-29518/com.gb.mybuoy D/MainActivity: /data/user/0/com.gb.mybuoy/databases/MyBuoy.db3 2021-09-18 13:25:01.228 29518-29518/com.gb.mybuoy D/MainActivity: /data/user/0/com.gb.mybuoy/databases/MyBuoy.db3 2021-09-18 13:25:22.772 29518-29518/com.gb.mybuoy E/SQLiteDatabase: Failed to open database 'MyBuoy.db3'. org.sqlite.database.sqlite.SQLiteCantOpenDatabaseException: unknown error (code 14): Could not open database at org.sqlite.database.sqlite.SQLiteConnection.nativeOpen(Native Method) at org.sqlite.database.sqlite.SQLiteConnection.open(SQLiteConnection.java:214) at org.sqlite.database.sqlite.SQLiteConnection.open(SQLiteConnection.java:198) at org.sqlite.database.sqlite.SQLiteConnectionPool.openConnectionLocked(SQLiteConnectionPool.java:466) at org.sqlite.database.sqlite.SQLiteConnectionPool.open(SQLiteConnectionPool.java:188) at org.sqlite.database.sqlite.SQLiteConnectionPool.open(SQLiteConnectionPool.java:180) at org.sqlite.database.sqlite.SQLiteDatabase.openInner(SQLiteDatabase.java:810) at org.sqlite.database.sqlite.SQLiteDatabase.open(SQLiteDatabase.java:795) at org.sqlite.database.sqlite.SQLiteDatabase.openDatabase(SQLiteDatabase.java:698) at org.sqlite.database.sqlite.SQLiteDatabase.openOrCreateDatabase(SQLiteDatabase.java:721) at org.sqlite.database.sqlite.SQLiteOpenHelper.getDatabaseLocked(SQLiteOpenHelper.java:259) at org.sqlite.database.sqlite.SQLiteOpenHelper.getWritableDatabase(SQLiteOpenHelper.java:199) at com.gb.mybuoy.MainActivity.onRequestPermissionsResult(MainActivity.java:122) at android.app.Activity.dispatchRequestPermissionsResult(Activity.java:7608) at android.app.Activity.dispatchActivityResult(Activity.java:7458) at android.app.ActivityThread.deliverResults(ActivityThread.java:4353) at android.app.ActivityThread.handleSendResult(ActivityThread.java:4402) at android.app.servertransaction.ActivityResultItem.execute(ActivityResultItem.java:49) at android.app.servertransaction.TransactionExecutor.executeCallbacks(TransactionExecutor.java:108) at android.app.servertransaction.TransactionExecutor.execute(TransactionExecutor.java:68) at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1808) at android.os.Handler.dispatchMessage(Handler.java:106) at android.os.Looper.loop(Looper.java:193) at android.app.ActivityThread.main(ActivityThread.java:6669) at java.lang.reflect.Method.invoke(Native Method) at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:493) at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:858) 2021-09-18 13:25:25.203 29518-29518/com.gb.mybuoy E/MainActivity: org.sqlite.database.sqlite.SQLiteCantOpenDatabaseException: unknown error (code 14): Could not open database

and Third try with sqlite-android-3360000.aar build and full path database who work fine: //import android.database.sqlite.SQLiteDatabase; //import android.database.sqlite.SQLiteOpenHelper; import org.sqlite.database.sqlite.SQLiteDatabase; import org.sqlite.database.sqlite.SQLiteOpenHelper;

public class AppDB extends SQLiteOpenHelper {

public static final int DATABASE_VERSION = 1;
public static final String DATABASE_NAME = "MyBuoy.db3";

public AppDB(Context context) {
    //super(context, DATABASE_NAME, null, DATABASE_VERSION);
    super(context, context.getDatabasePath(DATABASE_NAME).getPath(), null, DATABASE_VERSION);
}

../..

}

The Logs are : 2021-09-18 13:28:33.176 29884-29884/com.gb.mybuoy D/MainActivity: /data/user/0/com.gb.mybuoy/databases/MyBuoy.db3 2021-09-18 13:28:33.178 29884-29884/com.gb.mybuoy D/MainActivity: /data/user/0/com.gb.mybuoy/databases/MyBuoy.db3 2021-09-18 13:28:41.829 29884-29884/com.gb.mybuoy D/MainActivity: SQLiteDatabase: /data/user/0/com.gb.mybuoy/databases/MyBuoy.db3

So i investigated and this part of the code seems wrong : In file SQLiteOpenHelper.class private SQLiteDatabase getDatabaseLocked(boolean writable) { ../..

try {
    db = SQLiteDatabase.openOrCreateDatabase(this.mName, this.mFactory, this.mErrorHandler);
} catch (SQLiteException var15) {
    if (writable) {
        throw var15;
    }

    Log.e(TAG, "Couldn't open " + this.mName + " for writing (will try read-only):", var15);
    String path = this.mContext.getDatabasePath(this.mName).getPath();
    db = SQLiteDatabase.openDatabase(path, this.mFactory, 1, this.mErrorHandler);
}


../..

}

Why in the catch case there are a try with this.mContext.getDatabasePath(this.mName) path only in the not writable case ? Why in the default case this.mContext.getDatabasePath is not called ? Why i have to call supper class method like super(context, context.getDatabasePath(DATABASE_NAME).getPath(), null, DATABASE_VERSION) and pass to the second argument the full path base on the context then the context is in the first argument for that work done ?

The seems strange and seems wrong in that version of SQLiteOpenHelper ?!