I know this has been mentioned so many times before me and I've looked at so many posts already about it. I tried many different options to make this work and regardless no success. I think it is the many different variations of code that makes it so confusing.
What I have done is created a database with SQLite Expert program in windows called "time.db" I created 2 tables in this db. One called "main" the other called "android_metadata". I read that a table called android_metadata needs to be made or android OS will not be able to use this database. So, I created it and added a text field called "locale" with a default value of "en_US". I also read that I needed to create an Index in my "main" table as "_id" as an integer and primary key so I did that too.
I copied my time.db to my file assets directory and added it with the file manger in B4A.
Now for my code:
This is from an activity module. It is not the complete code but it contains the code that fails.
The line SQL1.ExecNonQuery2("INSERT INTO main (a,b,c,d,e) VALUES (?, ?, ?, ?, ?)", sColumn) is what fails with the table "main" cannot be found.
I looked on my S5 I'm using to test this with and the "time.db" file is located in a folder Device storage>Android>data>com.linear.time>files. This is where DBUtils.CopyDBFromAssets put it.
SQL1.Initialize(File.DirInternal,"time.db",True) does not fail as far as I can see.
So I'm stuck here and at a loss. There is my db file if someone wants to look at it.
Appreciate any help, thanks
What I have done is created a database with SQLite Expert program in windows called "time.db" I created 2 tables in this db. One called "main" the other called "android_metadata". I read that a table called android_metadata needs to be made or android OS will not be able to use this database. So, I created it and added a text field called "locale" with a default value of "en_US". I also read that I needed to create an Index in my "main" table as "_id" as an integer and primary key so I did that too.
I copied my time.db to my file assets directory and added it with the file manger in B4A.
Now for my code:
This is from an activity module. It is not the complete code but it contains the code that fails.
B4X:
Sub Process_Globals
Dim SQL1 As SQL
End Sub
Sub Globals
Dim su As StringUtils
End Sub
Sub Activity_Create(FirstTime As Boolean)
DBUtils.CopyDBFromAssets("time.db")
SQL1.Initialize(File.DirInternal,"time.db",True)
Try
SQL1.BeginTransaction
Dim lst1 As List
lst1 = su.LoadCSV(File.DirRootExternal & "/TcLogger","1.csv",",")
For i = 0 To lst1.Size - 1
Dim sColumn() As String
sColumn = lst1.Get(i)
SQL1.ExecNonQuery2("INSERT INTO main (a,b,c,d,e) VALUES (?, ?, ?, ?, ?)", sColumn)
Next
SQL1.TransactionSuccessful
Catch
Log(LastException.Message)
End Try
SQL1.EndTransaction
The line SQL1.ExecNonQuery2("INSERT INTO main (a,b,c,d,e) VALUES (?, ?, ?, ?, ?)", sColumn) is what fails with the table "main" cannot be found.
I looked on my S5 I'm using to test this with and the "time.db" file is located in a folder Device storage>Android>data>com.linear.time>files. This is where DBUtils.CopyDBFromAssets put it.
SQL1.Initialize(File.DirInternal,"time.db",True) does not fail as far as I can see.
So I'm stuck here and at a loss. There is my db file if someone wants to look at it.
Appreciate any help, thanks