NFOBoy Active Member Licensed User Longtime User Apr 22, 2012 #1 Ok, want to try and use the power/flexibility of SQL to store required file information. Currently, am using a simple .csv, with required audio clips parsed out, that are associated with each record. I have looked through and determined that using a Blob is technically possible to store practically any information in an SQL (many examples for images I have found). However, have not found a way to convert audio clips for storage and retrieval inside an SQLite database. I could just store the name of the audio clip (and then have the audio files separate from the database, which is what I am doing now) , but would be nice if it could actually be imbedded in the database. Is this actually possible (vice just technically... for my slow brain) Thanks, Ross
Ok, want to try and use the power/flexibility of SQL to store required file information. Currently, am using a simple .csv, with required audio clips parsed out, that are associated with each record. I have looked through and determined that using a Blob is technically possible to store practically any information in an SQL (many examples for images I have found). However, have not found a way to convert audio clips for storage and retrieval inside an SQLite database. I could just store the name of the audio clip (and then have the audio files separate from the database, which is what I am doing now) , but would be nice if it could actually be imbedded in the database. Is this actually possible (vice just technically... for my slow brain) Thanks, Ross
Erel B4X founder Staff member Licensed User Longtime User Apr 22, 2012 #2 Yes. You can store any file in a BLOB field. You can use this method to get the required bytes array: Code: Copy Sub GetBytesFromFile(Dir As String, FileName As String) As Byte() Dim out As OutputStream out.InitializeToBytesArray(100) Dim in As InputStream in = File.OpenInput(Dir, FileName) File.Copy2(in, out) Return out.ToBytesArray End Sub Upvote 0
Yes. You can store any file in a BLOB field. You can use this method to get the required bytes array: Code: Copy Sub GetBytesFromFile(Dir As String, FileName As String) As Byte() Dim out As OutputStream out.InitializeToBytesArray(100) Dim in As InputStream in = File.OpenInput(Dir, FileName) File.Copy2(in, out) Return out.ToBytesArray End Sub
T tmighty Member Licensed User Longtime User May 6, 2012 #3 And the other way around? How can I create an image file from an SQLite recordset? In VB6 can I simply say: Dim nBytes() As Byte nBytes = r!imageblob BytesToFile nBytes, "c:\temp\myimage.png" Edit: Here is the solution: http://www.b4x.com/forum/basic4android-getting-started-tutorials/6736-sql-tutorial.html ("ReadBlob") Last edited: May 6, 2012 Upvote 0
And the other way around? How can I create an image file from an SQLite recordset? In VB6 can I simply say: Dim nBytes() As Byte nBytes = r!imageblob BytesToFile nBytes, "c:\temp\myimage.png" Edit: Here is the solution: http://www.b4x.com/forum/basic4android-getting-started-tutorials/6736-sql-tutorial.html ("ReadBlob")