Vivek Singh
Vivek Singh

Reputation: 1241

When I'm retrieving blob value from SQLite it gives different value as it is stored in database

When I'm retrieving blob value from SQLite it gives different value as it is stored in database. I don't know why this is happening. When I'm using cursor.getString(), it gives the same value. But when I use curser.getBlob(), it gives different value. Also when I convert cursor.getString() value into bytes[] using getBytes() it again gets converted into different vlaue which is stored in database.

Please tell me the solution as am not able to find why this is happening.

Upvotes: 1

Views: 348

Answers (1)

Rahul Gautam
Rahul Gautam

Reputation: 1121

i think you have used insert query to insert data into sqlite database. in my opinion you shud use the following method to insert data also image.

CREATE TABLE IF NOT EXISTS " + DB_TABLE + "("+ 
               KEY_NAME + " TEXT," + 
               KEY_IMAGE + " BLOB);";

ContentValues cv = new  ContentValues();
cv.put(KEY_NAME,    name);
cv.put(KEY_IMAGE,   image);
database.insert( DB_TABLE, null, cv );

Use this method it should work. if not then plz let me know about it. Gud luck.

Upvotes: 2

Related Questions