Android Question Unable to connect to my SqliteCipher Database


Active Member
Licensed User
I create 2 SqliteCipher databases with 2 different software,

I have tables with data in them each
I downloaded the lastest libary and event the old one yet it keeps returning this error

** Service (starter) Start **
** Activity (main) Create, isFirst = true **
Error occurred on line: 95 (Main)
net.sqlcipher.database.SQLiteException: file is not a database: , while compiling: select count(*) from sqlite_master;
    at net.sqlcipher.database.SQLiteCompiledSql.native_compile(Native Method)
    at net.sqlcipher.database.SQLiteCompiledSql.compile(
    at net.sqlcipher.database.SQLiteCompiledSql.<init>(
    at net.sqlcipher.database.SQLiteProgram.<init>(
    at net.sqlcipher.database.SQLiteQuery.<init>(
    at net.sqlcipher.database.SQLiteDirectCursorDriver.query(
    at net.sqlcipher.database.SQLiteDatabase.rawQueryWithFactory(
    at net.sqlcipher.database.SQLiteDatabase.rawQuery(
    at net.sqlcipher.database.SQLiteDatabase.keyDatabase(
    at net.sqlcipher.database.SQLiteDatabase.openDatabaseInternal(
    at net.sqlcipher.database.SQLiteDatabase.openDatabase(
    at net.sqlcipher.database.SQLiteDatabase.openDatabase(
    at net.sqlcipher.database.SQLiteDatabase.openDatabase(
    at net.sqlcipher.database.SQLiteDatabase.openDatabase(
    at anyhwheresoftware.b4a.objects.sqlcipher.SQLCipher.Initialize(
    at b4a.example.main._activity_create(
    at java.lang.reflect.Method.invoke(Native Method)
    at java.lang.reflect.Method.invoke(Native Method)
    at anywheresoftware.b4a.ShellBA.raiseEvent2(
    at b4a.example.main.afterFirstLayout(
    at b4a.example.main.access$000(
    at b4a.example.main$
    at android.os.Handler.handleCallback(
    at android.os.Handler.dispatchMessage(
    at android.os.Looper.loop(
    at java.lang.reflect.Method.invoke(Native Method)
** Activity (main) Resume **

Please any suggestions on how to fix it?

Peter Simpson

Licensed User
@FrostCodes I find that the best one to use is (which you obviously already have).

1. Create your database in SQLite Browser and then goto Tools > Set Encryption to encryption your SQLite database.
2. Add your SQLite database into your B4A project
3. Select the SQLCipher and SQL libraries in B4A.
4. Before trying to access our SQLite database, copy your database out of the assets folder into RP.GetSafeDirDefaultExternal(""), use your database from the RP.GetSafeDirDefaultExternal("") folder location.

Make sure not to lose your encryption password.

Last edited:
Upvote 0

Peter Simpson

Licensed User
Hello @Peter Simpson yes I did the exact same steps as you described but still the same problem.

Would it be possible for you to try going through the procedure again, but this time with a blank database. That way if you come across the same issue again, you can at least attache the database and encryption password to your next post???

Actually here you go. I've attached a test project that I've just created for you. The cipher password is in the Starter service...


    20.5 KB · Views: 169
Upvote 0