I am trying to fetch a value by comparing two columns but my application crashes every time.
Cursor cursor= db.query(TABLE_IMAGES,
new String[]{"_id"},
name +" = ?" + time +" = ?",
开发者_运维知识库 new String[]{compareToThis, compare to that},
null, null, null);
Try the following:
Cursor cursor= db.query(TABLE_IMAGES,
new String[]{"_id"},
name +"=? AND " + time +"=?",
new String[]{compareToThis, compareToThat},
null, null, null);
Given that name
and time
variables are Strings, and compareToThis
and compareToThat
are the values for the parameters, that should work for you.
精彩评论