Android Question Test database location

PeterRodwell

New Member
Licensed User
Longtime User
I want to test a small database program with the AVD. Where do I have to put the database in my PC so that the program can find it?
 

LucaMs

Expert
Licensed User
Longtime User
A Sub of DBUtils:
B4X:
'Copies a database file that was added in the Files tab.
'The database must be copied to a writable location.
'This method copies the database to the storage card.
'If the storage card is not available the file is copied to the internal folder.
'The target folder is returned.
'If the database file already exists then no copying is done.
Sub CopyDBFromAssets (FileName As String) As String
 
Upvote 0

mangojack

Expert
Licensed User
Longtime User
Peter .. Are you utilizing DBUtils ? or dealing directly with SQLite ?

It is not neccessary to involve DBUtils to do what you wish , unless you've already gone down that path.

Just create a db file on your PC then include it in your app .. by way of the IDE Files tab as LucaMS suggested.
Run your app and copy the file to a writable location ie ..
B4X:
If File.Exists(File.DirDefaultExternal, "Database.db") = False Then
     File.Copy(File.DirAssets, "Database.db", File.DirDefaultExternal, "Database.db")
  End If

'then ...
  SQL1.Initialize(File.DirDefaultExternal, "Database.db", True)

'and start your SQL queries etc

Edit ..
If you do not already have these .. 2 Free DB Creation / Editing Software

SQLite Browser ... simple DB Create,View AND Edit program

SQLiteExpert Personal ... more options than above

Cheers mj
 
Last edited:
Upvote 0
Top