Where is the sqlite file is located?

systems1

Member
Licensed User
Longtime User
Hi all,

When we create a sqlite database where is the sqlite file located?

Please help me?
:sign0085::sign0085:
 
If you've created your db with a pc utility instead of creating it at real time using your code, and placed it in the files' section at the right side of b4a environment, then your file is 'located' at dirAssets. If that's the case then you should copy it to a location you choose, for example defaultExternal.
Code: Copy
If File.Exists(File.DirDefaultExternal,"yourDb.db")=False Then
File.Copy(File.DirAssets,"yourDb.db",File.DirDefaultExternal,"yourDb.db")
End If
 
Upvote 0
You can use DBUtils to copy the database from the assets folder. It first checks that there is a writable storage card and only then copies it.
Right. In the case of my coding, app can throw an error if no external storage is available (though I think I saw somewhere that today's devices create a pseudo-external storage in case no card is available).
 
Upvote 0
@mc73, just to tell you(although not related to the topic), normally, let's take for example a 16 GB phone. It has no hardware SD card. However, 1 GB of these are recognized as internal memory by the phone. The remaining 15 are emulated as SD Card in order to match the Android OS's need of SD card :).
 
Upvote 0
@mc73, just to tell you(although not related to the topic), normally, let's take for example a 16 GB phone. It has no hardware SD card. However, 1 GB of these are recognized as internal memory by the phone. The remaining 15 are emulated as SD Card in order to match the Android OS's need of SD card :).
Yes, that's what I think I saw, thank you :)
 
Upvote 0
Hi ,
I tried and modified your example
Dim DBFileDir As String : DBFileDir = File.DirRootExternal&"/Prezenta/"
If File.Exists(DBFileDir ,"countries.db")=False Then
File.Copy(File.DirAssets,"countries.db",DBFileDir ,"countries.db")
End If

I deployed directly on my tab , and i got this error :
File.copy(File.DirAssest,"countries.db",DBFileDir,"countries.db")
java.io.FileNotException:/mnt/sdcard/prezenta/countries.db : open failed:ENOENT(nos such file or directory)

The prezenta folder was created manualy on my external SDCard
I check if card is writable = true
what i did wrong ?
Thank you
 
Upvote 0
Back
Top