database upload issue

markh2011

Member
Licensed User
Longtime User
Hi, i have upgraded to 1.9 version & i am having an issue where i install my program with a small sqlite db.
The db appears in the folder on my phone but it does not have the tables or data.
The db has 2 tables with 600 records in one table & the other is empty.
i have then uploaded the db to the data folder and the app works correctly.
My other programs that have dbs are installing correctly.
Any ideas?
 

markh2011

Member
Licensed User
Longtime User
Yes i am using dbutils.
Got it working now after recreating db under different name.
Very weird as i have not had this issue with other programs i have created.
 
Last edited:
Upvote 0

markh2011

Member
Licensed User
Longtime User
I thought i had fixed but after i uninstalled & reinstalled the app it has happened again.
I have upgraded to version 2 of the b4a bridge & that has made no difference as well.
It does not happen with any other apps i have created & they all use basically the same code.
I have tried just deleting the db & then reinstalling the app again & no matter what i do i cant get the db copied correctly.

This is not resolved & still a problem so if anybody has any ideas i would really appreciate some input.
Erel this is the project i sent to you.
 
Upvote 0

Erel

B4X founder
Staff member
Licensed User
Longtime User
This is your initialization code:
B4X:
Sub Activity_Create(FirstTime As Boolean)
      ab.initialise
      dbutils.CopyDBFromAssets("birdrefaust.db")
      If File.Exists(DBFilePath, DBFileName) = False Then
      If FirstTime Then 
         SQL1.Initialize(DBFilePath, DBFileName, True)
         GPS2.Initialize("GPS")
         GPS2.stop
         GPS2.start(0,0)
      End If
   Else
      If FirstTime Then
         SQL1.Initialize(DBFilePath, DBFileName, True)
         GPS2.Initialize("GPS")
         GPS2.stop
         GPS2.start(0,0)
      End If
   End If

You should change it to:
B4X:
      If FirstTime Then
         DBFilePath = dbutils.CopyDBFromAssets("birdrefaust.db")
         SQL1.Initialize(DBFilePath, DBFileName, False)
         GPS2.Initialize("GPS")
         GPS2.stop
         GPS2.start(0,0)
      End If

Make sure that your device doesn't already have such a file.
 
Upvote 0
Top