I have a SQLite database in which I store images as a BLOB using this code
URL url = new URL("http://t0.gstatic.com/images?q=tbn:ANd9GcRsaLl3TGB4W2hJFN_Wh0DNVPQEYGtweNsqvTXVtwE8FXR300-Ut-npgS4"); //open the connection URLConnection ucon = url.openConnection(); //buffer the download InputStream is = ucon.getInputStream(); BufferedInputStream bis = new BufferedInputStream(is,128); ByteArrayBuffer baf = new ByteArrayBuffer(128); //get the bytes one by one int current = 0; while ((current = bis.read()) != -1) { baf.append((byte) current); } mydb = openOrCreateDatabase(DBNAME, Context.MODE_PRIVATE,null); mydb.execSQL("INSERT INTO " + TABLE + "(IMAGE) VALUES('" + baf.toByteArray() + "')"); mydb.close();
When I try to restore the image, I get the following error:
Factory returned null
My Select Query is
mydb = openOrCreateDatabase(DBNAME, Context.MODE_PRIVATE,null); Cursor allrows = mydb.rawQuery("SELECT * FROM "+ TABLE, null); if(allrows.getCount() > 0){ allrows.moveToNext(); System.out.println("3333"); ImageView myImage = (ImageView) findViewById(R.id.ImageView01); byte[] bb = allrows.getBlob(1); System.out.println("VVV " + bb);
Please, help.
source share