dbUtils - error no such table

dougc

Member
Licensed User
Longtime User
i have a DB called (bowling.sqlite) with a table called games that everytime dbutils tries to write to it I get the error:

InsertMaps (first query out of 1): INSERT INTO [games] ([date], [score]) VALUES (?, ?)
(SQLiteException) android.database.sqlite.SQLiteException: no such table: games (code 1): , while compiling: INSERT INTO [games] ([date], [score]) VALUES (?, ?)

the code is:

B4X:
 Dim ListOfMaps As List
   ListOfMaps.Initialize 

   Dim m As Map
   m.Initialize
   
   'm.Put("Id", Id)
   m.Put("date", DateTime.Date(DateTime.Now))
   m.Put("score", Main.totalScore)
   ListOfMaps.Add(m)

   DBUtils.InsertMaps(SQL, "games", ListOfMaps)

here is the code to copy the DB to my phone
B4X:
If File.Exists(File.DirDefaultExternal, DBFileName) = False Then
          DBFileDir = DBUtils.CopyDBFromAssets(DBFileName)
         Log("copied DB to device ....")
End If

and here is my process_globals section
B4X:
 Dim SQL As SQL
   
   Dim DBFileName As String            : DBFileName = "bowling.sqlite"
   Dim DBFileDir As String               : DBFileDir = File.DirDefaultExternal

i have tried doing an insert to the DB using firefox's sqlite plugin (which works just fine). Verified that the DB is on my phone (/storage/sdcard/Android/data/bagofchipapps.com.bowlingLogger/files)

and I installed a sqlite DB viewer and looked at the database ON my phone and see the games table just fine.

I am using dbutils versions 1.09, I am sure I am missing something but its escaping me, any suggestions/advice is appriciated

thanks

dougc
 

dougc

Member
Licensed User
Longtime User
sorry I missed that line when copying

B4X:
SQL.Initialize(File.DirRootExternal, "bowling.sqlite", True)
 
Upvote 0

mc73

Well-Known Member
Licensed User
Longtime User
In your previous code you are using dirDefaultExternal, thus this line should be:
B4X:
SQL.Initialize(File.DirDefaultExternal, "bowling.sqlite", True)
 
Upvote 0
Top