Android Question SQLCipher

Cassie

Member
Licensed User
Hi Guys,

Im working with this SQLCipher but unfortunately i the app closes after initialization of db

Dim SQLCipher1 As SQLCipher -- This was declare in process global

If SQLCipher1.IsInitialized = False Then
SQLCipher1.Initialize(File.DirInternal,"bond.db",False,DBPASSWORD,"")
End If

Dim Cursor1 As Cursor

APPLICATION STOPS HERE:

Unfortunately, <Application Name> has stopped.

Cursor1 = SQLCipher1.ExecQuery("SELECT transaction_no FROM transactions")
Cursor1.Position=0
Msgbox(Cursor1.GetString("transaction_no"), "")

I have already copied the icudt46l on the asset directory.

Thanks in advance.
 

Cassie

Member
Licensed User
Moved to the questions forum.

1. Please use [code]code here...[/code] tags when posting code.

2. Run your app in debug mode and post the error message from the logs.

Thanks for the tip, I'm trying to famliarize procedures and hot to's in this forum. Anyway, I'll try to check it again in debug mode. Thank You.
 
Upvote 0

Cassie

Member
Licensed User
Hi,

I tried to run it on debugger but it seems after the Log("Execute SELECT query here.") the application closed and stop.

B4X:
Sub Activity_Create(FirstTime As Boolean)
   File.Copy(File.DirAssets,"bond.db",File.DirInternal,"bond.db")
  
   If SQLCipher1.IsInitialized = False Then
     SQLCipher1.Initialize(File.DirInternal,"bond.db",False,DBPASSWORD,"")
     Dim Cursor As Cursor
     Cursor = SQLCipher1.ExecQuery ("PRAGMA cipher_migrate") '<==== only enter this line
    
     Log("Execute SELECT query here.")
    
     Cursor = SQLCipher1.ExecQuery("SELECT * FROM transactions")
     Cursor.Position =0
     Msgbox(Cursor.GetString("transaction_no"), "")
   End If
  
End Sub

And here is the log file
** Service (starter) Create **
** Service (starter) Start **
** Activity (main) Create, isFirst = true **
Execute SELECT query here.
Connected to B4A-Bridge (Wifi)
sending message to waiting queue (CallSubDelayed - UpdateStatus)
Ignoring event (too many queued events: CallSubDelayed - UpdateStatus)

Anyways, I'm using SQLiteStudio 3.1.1 when creating a SQLCipher database.

Thanks in advance.
 
Upvote 0

Erel

B4X founder
Staff member
Licensed User
Your code is wrong, though it is not the cause of this error.
You need to initialize SQLCipher once in Service_Create of the starter service. Your current code will copy the original file multiple times.

My guess is that SQLiteStudio uses a different version of SQLCipher. Try to create the database on the device and see whether it works.

You can switch to USB debug mode instead of B4A-Bridge. It will show the error message.
 
Upvote 0

Cassie

Member
Licensed User
Your code is wrong, though it is not the cause of this error.
You need to initialize SQLCipher once in Service_Create of the starter service. Your current code will copy the original file multiple times.

My guess is that SQLiteStudio uses a different version of SQLCipher. Try to create the database on the device and see whether it works.

You can switch to USB debug mode instead of B4A-Bridge. It will show the error message.

Hi Erel,

Thanks for the tip, maybe you're right the my SQLiteStudio uses different version of SQLCipher. I tried to create SQLCipher database programmatically in the device and it works perfectly.

Thank you very much.
 
Upvote 0
Top