How to reference an external SQLite database?

Sanxion

Active Member
Licensed User
Longtime User
Hi

I have just started using Basic4android to create a database application and have encountered a slight problem. I have created an SQLite database - using SQLite Database Browser - and was wondering how to reference this using my code. I have taken the following from the beginners guide:

' initilize the database
If File.Exists(DBFileDir, DBFileName) = False Then
If FirstTime Then
File.Copy(File.DirAssets, DBFileName, DBFileDir, DBFileName)
SQL1.Initialize(DBFileDir, DBFileName, True)
End If
Else
If FirstTime Then
SQL1.Initialize(DBFileDir, DBFileName, True)
End If
End If

Could somebody please describe the necessary steps required?

Thank-you in advance.
 

Cableguy

Expert
Licensed User
Longtime User
SQL1 is a Library reference, and since you are using the Demo B4A, you will NOT be able to use it...
In order to use Libraries in your projects, you need to buy B4A...
 
Upvote 0

Cableguy

Expert
Licensed User
Longtime User
Then you need to e-mail EREL so that your status in the forum reflects that ( you are missing a star under your nickname, as all registered users of B4A have)...
Then you will, if you haven already, be given a link to download B4AFull and a License file...
After that, you can even download the Libraries from the Forum developed by other users
 
Upvote 0

klaus

Expert
Licensed User
Longtime User
You should read the Beginner's Guide more deeply.
At page 151 you have the definition of the variables used in the initialize part of the code.
To be able to access the database you should add the file to your project in the file tab in the lower right corner of the IDE. Then the file is in the File.DirAssets directory.
But you must copy the database file to another folder in the device for example File.DirInternal or File.DirRootExternal.
You must declare the variables and the database as explained on page 151.
DBFileName = file name of your database
DBFileDir = either File.DirInternal or File.DirRootExternal
Have a look at the source code of the example from the Beginner's Guide.

Best regards.
 
Upvote 0

Cableguy

Expert
Licensed User
Longtime User
Nice to see you got your star.
 
Upvote 0
Top