Sqlite table on sd-card

fatman

Active Member
Licensed User
Longtime User
Hi to all,

my hardware is a toshiba thrive and the situation is like that: on the sd-card i have a folder called data and a sqlite-table called stock.db e.g. /data/stock.db
I can see the table using the filemanager on the tablet.

This code fails to work:

Sub Process_Globals
Dim SQL1 As SQL
End Sub
...
Sub Activity_Create(FirstTime As Boolean)
MyDir = File.DirRootExternal & "/data"
MyFile = "stock.db"
SQL1.Initialize(MyDir, MyFile, False) :BangHead:
End Sub

Program will pause on the device... showing "SQL1.Initialize(MyDir, myFile, False)"

Hope you have any ideas why i cannot get in touch with that table.

Thanks
 

stevel05

Expert
Licensed User
Longtime User
It's a good idea to use File.Combine when building file addresses. That may not be what's giving you the problem here but have a look at the log (3rd tab bottom right in the IDE). That should give you more information when it fails. If necessary, turn off the filter.
 
Upvote 0

fatman

Active Member
Licensed User
Longtime User
Thanks stevel05!

My solution (after a long search) is this: :)

MyFile = "stock.lit"
mydir = File.Combine(File.DirRootExternal, "sdcard-disk0/data/")
SQL1.Initialize(mydir, Myfile, False)

The reason seems to be my Toshiba Thrive... The full path to my table is like that:
/storage/sdcard-disk0/data/stock.lit

After reading a lot in the forum I got the impression that the path to sd-cards depends on the device...
 
Upvote 0

stevel05

Expert
Licensed User
Longtime User
On the devices I have, DirDefaultExternal either points to the devices inbuilt additional memory (if it has any) or the SDCard. If you are building the app for distribution you would be safer using that rather than directly addressing a file that you have already stored.

You can add the file to the apk for distribution via the files tab (subject to size) then copy it from File.DirAssets to File.DirDefaultExternal the first time the app is run. You will then be able to find it on all devices.
 
Upvote 0
Top