Titanium JIRA Archive
Titanium SDK/CLI (TIMOB)

[TIMOB-12447] Android: Cannot convert BLOB image to string using SQL

GitHub Issuen/a
TypeBug
PriorityHigh
StatusClosed
ResolutionFixed
Resolution Date2013-10-18T22:25:23.000+0000
Affected Version/sn/a
Fix Version/s2013 Sprint 12 API, 2013 Sprint 12, Release 3.2.0
ComponentsAndroid
Labelsmodule_database, triage
ReporterTim Varney
AssigneeSunila
Created2012-12-18T14:51:41.000+0000
Updated2013-10-18T22:25:27.000+0000

Description

Attachments

FileDateSize
flower.jpg2013-06-20T20:08:16.000+000017766

Comments

  1. Alberto Marcone 2013-03-29

    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.
  2. Sunila 2013-06-13

    Blob support for read and write added https://github.com/appcelerator/titanium_mobile/pull/4386
  3. Allen Yeung 2013-06-19

    [~sunila] Please attach the test case with the sqlite file that you used.
  4. Sunila 2013-06-20

    Here is the test case 1. Run the following:
       var 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();
       
    Expected Result: The image should load and show up Actual Result: Only the splash screen appears
  5. Federico Casali 2013-10-18

    Verified working as expected. TiSDK 3.2.0.v20131017152001 CLI 3.2.0 Titanium Studio 3.2.0.201310152326 Closing.

JSON Source