[TIMOB-12447] Android: Cannot convert BLOB image to string using SQL
| GitHub Issue | n/a |
|---|---|
| Type | Bug |
| Priority | High |
| Status | Closed |
| Resolution | Fixed |
| Resolution Date | 2013-10-18T22:25:23.000+0000 |
| Affected Version/s | n/a |
| Fix Version/s | 2013 Sprint 12 API, 2013 Sprint 12, Release 3.2.0 |
| Components | Android |
| Labels | module_database, triage |
| Reporter | Tim Varney |
| Assignee | Sunila |
| Created | 2012-12-18T14:51:41.000+0000 |
| Updated | 2013-10-18T22:25:27.000+0000 |
Description
Attachments
| File | Date | Size |
|---|---|---|
| flower.jpg | 2013-06-20T20:08:16.000+0000 | 17766 |
I know that this ticket hasn't been scheduled yet, but don't you think that is an high priority bug? There's _no way_ (no workaround whatsoever) to retrieve a BLOB from a sqlite DB in Android.
Blob support for read and write added https://github.com/appcelerator/titanium_mobile/pull/4386
[~sunila] Please attach the test case with the sqlite file that you used.
Here is the test case 1. Run the following:
Expected Result: The image should load and show up Actual Result: Only the splash screen appearsvar win1 = Titanium.UI.createWindow({ title: 'Window1' }); var imageFile = Titanium.Filesystem.getFile('flower.jpg'); var oneImage = imageFile.read(); var db = Ti.Database.open('mbtiles'); // Initialize the database db.execute('CREATE TABLE IF NOT EXISTS images (tile_data BLOB, tile_id TEXT)'); db.execute('CREATE TABLE IF NOT EXISTS map (zoom_level INTEGER, tile_column INTEGER, tile_row INTEGER, tile_id TEXT)'); db.execute("DELETE FROM images"); db.execute("DELETE FROM map"); db.execute("INSERT INTO images (tile_id,tile_data) VALUES(?,?)", 1, oneImage); db.execute("INSERT INTO map (zoom_level,tile_column,tile_row,tile_id) VALUES(?,?,?,?)", 1, 1, 1, 1); var rows = db.execute("SELECT tile_data FROM images INNER JOIN map ON images.tile_id = map.tile_id"); var theImg = null; while (rows.isValidRow()) { theImg = rows.field(0); rows.next(); } rows.close(); db.close(); var imageView = Titanium.UI.createImageView( { image : theImg, width : 480, height : 640 }); win1.add(imageView); win1.open();Verified working as expected. TiSDK 3.2.0.v20131017152001 CLI 3.2.0 Titanium Studio 3.2.0.201310152326 Closing.