Android Question SQLite viewer

RB Smissaert

Well-Known Member
Licensed User
Longtime User
Just started with B4A and installed on Windows 7 Pro. I downloaded the SQLite viewer demo project and it compiled fine and runs (via the bridge app) on a Samsung S9. All good sofar. I copied a SQLite database from the PC to the SD card. File extension is .db3. When I try to load the file I get: Error loading database.
I runs fine on the PC in my own custom Excel SQLite add-in. There is no encryption.
Any idea what the problem could be? On the PC I run latest 3.22.0. Do I need to install SQLite on the phone?
Thanks for any advice.

RBS
 

RB Smissaert

Well-Known Member
Licensed User
Longtime User
I didn't alter the example code (posted a few months ago by Erel) at all.
I thought that all this would be handled by the file dialog.
At work now, but will have a look at the code later.

Thanks, RBS
 
Upvote 0

Star-Dust

Expert
Licensed User
Longtime User
What is the precise error he reports?
What example of Erel are you using? What version of B4A do you use and what version of Android?
 
Upvote 0

klaus

Expert
Licensed User
Longtime User
I thought that all this would be handled by the file dialog.
Yes, it should.

What exact error message do you get and in what line?
Set a breakpoint at the line SQL.Initialize(Dir, FileName, False) and look at the content of Dir and File.
Are these contents correct?

Execute the program step by step with this button
upload_2018-3-26_11-46-42.png
and watch what happens.

upload_2018-3-26_11-46-9.png


C:\Users\klaus\AppData\Local\Temp\SNAGHTML2101dd19.PNG


C:\Users\klaus\AppData\Local\Temp\SNAGHTML21019f55.PNG
 
Last edited:
Upvote 0

Star-Dust

Expert
Licensed User
Longtime User
Yes, it should.

What exact error message do you get and in what line?
Set a breakpoint at the line SQL.Initialize(Dir, FileName, False) and look at the content of Dir and File.
Are these contents correct?

Execute the program step by step with this button View attachment 65916 and watch what happens.

View attachment 65915
C:\Users\klaus\AppData\Local\Temp\SNAGHTML21019f55.PNG
The second and third images are not seen
 
Upvote 0

klaus

Expert
Licensed User
Longtime User
The second and third images are not seen
There are only two images.
I don't know why there are the two IMG texts, I tried to remoe them witout success.
 
Last edited:
Upvote 0

RB Smissaert

Well-Known Member
Licensed User
Longtime User
Done some debugging now and got this:

It fails on this line:
SQL.Initialize(Dir, FileName, False)
in:
Sub LoadDatabase(Dir As String, FileName As String)

These are the values for Dir and FileName:
ContentDir and content://com.android.externalstorage.documents/document/3637-6230%3ASQLite%2Fwordsdb.db

Not sure these values are right.
The DB file is on my SD card in a folder called SQLite and the file is called wordsdb.db

BTW, I have no visual indication in the IDE where the breakpoint is set (normally in VB6/VBA you will get brown line).
Is this normal? Is there a setting somewhere to get this?

RBS
 
Upvote 0

Star-Dust

Expert
Licensed User
Longtime User
What are the values of Dir and filename?
 
Upvote 0

klaus

Expert
Licensed User
Longtime User
For breakpoints you may have a look at the B4X IDE Booklet.
Chapter 7.1 Debugging and more specific chapter 7.1.2.5 Breakpoints

Do you see the database file in the internal file manager dialog?

Can you post your DB file so we could test it.

In the Main code of the SQLiteViewer you should remove these lines:
Dim Label2 As Label
Label2.Visible = False

Label2 doesn'exist in the layout.
 
Upvote 0

RB Smissaert

Well-Known Member
Licensed User
Longtime User
Stepping through the code worked fine and I could see all the variables and post Dir and FileName:

Dir: ContentDir
FileName: content://com.android.externalstorage.documents/document/3637-6230%3ASQLite%2Fwordsdb.db

Not sure what this all means, but doesn't look right to me.

I have taken out Label2.

When I am running from B4A via the bridge app, I can't see the DB file in the internal filemanager, but I can via
the external file manager. The DB file I am testing with is wordsdb.db and this is posted in one of the forums, I think
a search will find it. I picked this one as I know it can work from that thread.

I have a feeling the dialog just passes me the wrong file path. I have downloaded the latest Dialogs library, 4.01.
I will look at your more simple example now.

Not sure what happened this thread. I do realise I posted to the wrong group and take it has redirected, but I can't see in it Android questions.


RBS
 
Upvote 0

RB Smissaert

Well-Known Member
Licensed User
Longtime User
I tried your SQLiteLight1 and that works all fine.
So, to me it looks the Dialogs library has problems passing the right path string of the SD card.
I see you used File.DirInternal instead. I take it this is on the phone, but I can't find that folder
on the phone. Searched for persons.db, but couldn't find it.
At least I know now that SQLite works. Can't get it to run though from the phone desktop icon, as
I get Waiting for the IDE debugger to connect.

RBS
 
Upvote 0
Top