I have a project that take 8 image using camera intent.
I put the picture in B4XImageView, after that I get the bitmap and save it to SQLite.
Few reason why I must save to SQLite.
- I need to send this bitmap (will be converted to Base64) to web server via HTTP Post. After that the Base64 Image will be converted back as JPG and put in folder.
- User won't able to delete the image because it's won't show in file manager or gallery. It also save the hassle for user to delete the old image because old data will be set to delete from SQLite when the data is over 1 month old.
The problem I have is, when I try to retrieve the file using Result Set (ExecQuery2), it give SQLiteBlobTooBigException on resultSet.NextRow.
I also try cursor and have same exception.
I have read that cursor have max size which is 1 MB.
Is there any work around?
- I need to send this bitmap (will be converted to Base64) to web server via HTTP Post. After that the Base64 Image will be converted back as JPG and put in folder.
- User won't able to delete the image because it's won't show in file manager or gallery. It also save the hassle for user to delete the old image because old data will be set to delete from SQLite when the data is over 1 month old.
Progress column will be inserted an integer value.
I have the field on my complete project.
User won't able to save if progress field is empty or not number.
All column will be inserted with value, hence why I did not specify column name.
And you also missed the part where the error occurs.
Without the code that giving the error, I doubt anyone could guess the problem.
What I could guess is your code is trying to convert binary/blob value into probably a text type column or vice versa, due to the value of Picture1 has been inserted into column Progress.
And you also missed the part where the error occurs.
Without the code that giving the error, I doubt anyone could guess the problem.
What I could guess is your code is trying to convert binary/blob value into probably a text type column or vice versa, due to the value of Picture1 has been inserted into column Progress.
Public Sub SelectArray(query As String, param() As Object) As List
Dim result As List
result.Initialize
Dim resultSet As ResultSet = sqlLite.ExecQuery2(query, param)
Dim columnCount As Int = resultSet.ColumnCount
Do While resultSet.NextRow
Dim valueMap As Map
valueMap.Initialize
valueMap.Clear
For j = 0 To columnCount - 1
If resultSet.GetColumnName(j).Contains("ResourceData") Then
valueMap.Put(resultSet.GetColumnName(j), resultSet.GetBlob2(j))
Else
valueMap.Put(resultSet.GetColumnName(j), resultSet.GetString2(j))
End If
Next
result.Add(valueMap)
Loop
resultSet.Close
Return result
End Sub
And it give
B4A:
android.database.sqlite.SQLiteBlobTooBigException: Row too big to fit into CursorWindow requiredPos=0, totalRows=1
True.
But my objective is so user cannot tinkering with the photo (either edit or delete the photo from File Manager or Gallery because its work related).
Also the other reason is user is not always have a network connection because the user is on the site, that's why the system is set to save the data first in the phone instead of sending it directly to server.
Because of that reason is why I try to save to SQLite.
I think I'll make a new table to store the image per row and convert it to byte using OutputStream and compress using quality of 40.
So one main data will have 8 rows of image.
This will make the image per row is not over 1MB and will be cleared periodically.
So why don't you save your files in app internal storage where the user and file managers cannot reach it, and just save the filepath and the file creation date in the database? Don Manfred was right.