0

I have a table in which my 2nd field is of type blob. Now when i am trying to access the contents of this field i am getting the following error.

CODE

SQLiteDatabase sb= openOrCreateDatabase("/data/data/helios.maggi/Recipe.db",SQLiteDatabase.CREATE_IF_NECESSARY,null);
if(sb.isOpen())
   Log.i("mytag","the database is open "+sb.getPath());
   //sb.execSQL("drop database Recipe");
   Cursor c = sb.rawQuery("SELECT * FROM RecipeDetails", null);
   byte []myarray = c.getBlob(c.getColumnIndex("recipeimage"));

ERROR

02-06 19:54:16.626: ERROR/AndroidRuntime(1812): Caused by: android.database.CursorIndexOutOfBoundsException: Index -1 requested, with a size of 4

What is causing this error? I have verified that the content of the field recipeimage is blob, this is because i extracted the table from the device and checked the field names myself. the second field is of type blob and has 4 entries.

1 Answer 1

1

Apply this

Cursor c=db.query (String table, String[] columns, String selection, String[] selectionArgs, String groupBy, String having, String orderBy) 

Example

get the name of the Student from the student table to apply this query.

Cursor c=db.query ("student",null,"name like 'jon'",null,null,null,null); 
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.