Android Question Unable to connect to my SqliteCipher Database

FrostCodes

Active Member
Licensed User
I create 2 SqliteCipher databases with 2 different software,
1. https://sqlitestudio.pl/
2. https://sqlitebrowser.org/

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

B4X:
** 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(SQLiteCompiledSql.java:91)
    at net.sqlcipher.database.SQLiteCompiledSql.<init>(SQLiteCompiledSql.java:64)
    at net.sqlcipher.database.SQLiteProgram.<init>(SQLiteProgram.java:89)
    at net.sqlcipher.database.SQLiteQuery.<init>(SQLiteQuery.java:48)
    at net.sqlcipher.database.SQLiteDirectCursorDriver.query(SQLiteDirectCursorDriver.java:60)
    at net.sqlcipher.database.SQLiteDatabase.rawQueryWithFactory(SQLiteDatabase.java:1867)
    at net.sqlcipher.database.SQLiteDatabase.rawQuery(SQLiteDatabase.java:1785)
    at net.sqlcipher.database.SQLiteDatabase.keyDatabase(SQLiteDatabase.java:2486)
    at net.sqlcipher.database.SQLiteDatabase.openDatabaseInternal(SQLiteDatabase.java:2415)
    at net.sqlcipher.database.SQLiteDatabase.openDatabase(SQLiteDatabase.java:1149)
    at net.sqlcipher.database.SQLiteDatabase.openDatabase(SQLiteDatabase.java:1116)
    at net.sqlcipher.database.SQLiteDatabase.openDatabase(SQLiteDatabase.java:1065)
    at net.sqlcipher.database.SQLiteDatabase.openDatabase(SQLiteDatabase.java:1019)
    at anyhwheresoftware.b4a.objects.sqlcipher.SQLCipher.Initialize(SQLCipher.java:52)
    at b4a.example.main._activity_create(main.java:493)
    at java.lang.reflect.Method.invoke(Native Method)
    at anywheresoftware.b4a.shell.Shell.runMethod(Shell.java:732)
    at anywheresoftware.b4a.shell.Shell.raiseEventImpl(Shell.java:351)
    at anywheresoftware.b4a.shell.Shell.raiseEvent(Shell.java:255)
    at java.lang.reflect.Method.invoke(Native Method)
    at anywheresoftware.b4a.ShellBA.raiseEvent2(ShellBA.java:144)
    at b4a.example.main.afterFirstLayout(main.java:104)
    at b4a.example.main.access$000(main.java:17)
    at b4a.example.main$WaitForLayout.run(main.java:82)
    at android.os.Handler.handleCallback(Handler.java:790)
    at android.os.Handler.dispatchMessage(Handler.java:99)
    at android.os.Looper.loop(Looper.java:164)
    at android.app.ActivityThread.main(ActivityThread.java:6666)
    at java.lang.reflect.Method.invoke(Native Method)
    at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:445)
    at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:906)
** Activity (main) Resume **
Please any suggestions on how to fix it?
 

Peter Simpson

Expert
Licensed User
@FrostCodes I find that the best one to use is https://sqlitebrowser.org/ (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.

Enjoy...
 
Last edited:

Peter Simpson

Expert
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...
 

Attachments

Top