Put a type in a blob in sqlite?

Ricky D

Well-Known Member
Licensed User
Longtime User
Is it possible to save a map or list of types into a sqlite table?

I know I can do it easily with randomaccessfile but would like to do it in sqlite.

Regards, Ricky
 

Ricky D

Well-Known Member
Licensed User
Longtime User
Thanks Erel I'll try that later when I'm at my place.

Regards, Ricky
 
Upvote 0

salmander

Active Member
Licensed User
Longtime User
Erel, Can you please give me an example code for this?
 
Upvote 0

salmander

Active Member
Licensed User
Longtime User
This is how I am saving the MAP as a BLOB
B4X:
Dim ra As RandomAccessFile
   ra.Initialize(File.DirDefaultExternal, "temp1.dat", False)
   ra.WriteObject(AllServiceOperations, False, 0)
   ra.Close
   Dim os1 As OutputStream
   Dim is1 As InputStream
   is1 = File.OpenInput(File.DirDefaultExternal, "temp1.dat")
   os1.InitializeToBytesArray(1000)
   File.Copy2(is1, os1)
   Dim bytes1() As Byte
   bytes1 = os1.ToBytesArray
   'ra.ReadBytes(bytes1, 0, bytes1.Length, 0)
   sql1.ExecNonQuery2("UPDATE tblJobs SET all_operations=? WHERE device_job_id=?", Array As Object(bytes1, device_job_id))
   File.Delete(File.DirDefaultExternal, "temp1.dat") ' deleting the temp file.


I can see the data in the database by sqlite viewer app.

I can't seem to read it and convert it to map
here is what I am trying
B4X:
Dim output1() As Byte
      If sql1.IsInitialized = False Then sql1.Initialize(File.DirDefaultExternal, "jobs.db", True)
      output1 = sql1.ExecQuerySingleResult2("SELECT all_operations FROM tblJobs WHERE device_job_id=?", Array As String(device_job_id))
      Dim is1 As InputStream
      is1.InitializeFromBytesArray(output1, 0, output1.Length)
      Dim os1 As OutputStream
      os1.InitializeToBytesArray(1000)
      File.Copy2(is1, os1)
      Dim ra As RandomAccessFile
what do I do next? Please help?
 
Upvote 0
Cookies are required to use this site. You must accept them to continue using the site. Learn more…