Android Question Problem saving data quickly in SqLite

carlos7000

Active Member
Licensed User
Hi all.

I'm trying to save some of the data I get from the gps in a database.

With the following code I have no problems.

B4X:
Query = "INSERT INTO `GpsData`(`Id`,`UnixTime`,`Lat`,`Lon`,`Speed`,`Bearing`) VALUES (NULL,'" & UnixTime & "','" & Lat & "','" & Lon & "','" & Speed & "','" & Bearing & "');"
Sql1.ExecNonQuery(Query)
Unfortunately the code runs very slow. On average it takes 1 second to execute.
Looking for ways to improve performance I wrote this new code:

B4X:
Sql1.BeginTransaction
Sql1.ExecNonQuery2("INSERT INTO GpsData VALUES(NULL,?,?,?,?,?)", Array As String(UnixTime, Lat, Lon, Speed, Bearing))   
Sql1.EndTransaction
The code runs quickly. On average, the execution time is 50 thousandths of a second, but when reviewing the database, there is no data.

Neither on the phone nor in the log, there is a message of any error.

What could be the problem?
 
Top