SQLite DB error

JonPM

Well-Known Member
Licensed User
Longtime User
I have an app near completion. It contains a SQLite database with one table named "main". Everything works corrects on my HTC Rezound, but when I put the app on my DroidX I get the following error:

android.database.sqlite.SQLiteException: no such column:FirstName: , while compiling: SELECT FirstName, LastName FROM main ORDER BY FirstName

For a fact the columns exist (and as proof everything works perfectly fine on my HTC), so why doesn't it work on the DroidX?

This is my first app using SQLite db. Are there any known compatibility issues with android?
 

JonPM

Well-Known Member
Licensed User
Longtime User
How are you copying the database?

B4X:
If FirstTime Then
      If File.Exists(File.DirInternal, DBFileName) = False Then
         DBFileDir = DBUtils.CopyDBFromAssets(DBFileName)
      End If
      SQL1.Initialize(DBFileDir, DBFileName, True)
...

DBFileDir = File.DirInternal
 
Upvote 0

JonPM

Well-Known Member
Licensed User
Longtime User
I wonder if it is because the app gets installed to sdcard? I will try disabling this when I get home tonight.
 
Last edited:
Upvote 0

klaus

Expert
Licensed User
Longtime User
Looking at the CopyDBFromAssets routine you'll see that it copies the database to the DirDefaultExternal folder if possible otherwise to File.DirInternal.
B4X:
Sub CopyDBFromAssets (FileName As String) As String
    Dim TargetDir As String
    If File.ExternalWritable Then TargetDir = File.DirDefaultExternal Else TargetDir = File.DirInternal
    If File.Exists(TargetDir, FileName) = False Then
        File.Copy(File.DirAssets, FileName, TargetDir, FileName)
    End If
    Return TargetDir
End Sub
Best regards.
 
Upvote 0

JonPM

Well-Known Member
Licensed User
Longtime User
Another question. Since I don't plan on modifying the db at all from within the app, should I just keep it in DirAssests? Would that affect performance at all? would that interfere with commands like sort?
 
Upvote 0
Top