Retriveing blob content from sqlite database error
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.
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);
精彩评论