Reputation: 31
I entered the following code for comparing the records with the database records. It is executing but it shows already exists for every entering record (it may be an old or new record.)
boolean ifExisting() {
//Cursor c = db.rawQuery("SELECT * FROM sharelist WHERE category='"+str1+"'",null);
Cursor c = db.rawQuery("SELECT * FROM sharelist WHERE" + "category" + "=" + category,null);
Integer a=new Integer(c.getCount());
Log.e("getcount",a.toString());
if(c.getCount()>-1)
{ return false;}
else{
return true;
}
please help me.
Upvotes: 0
Views: 92
Reputation: 9961
Possible issues:
category
with the word WHERE
.Integer
function do any kind of rationalisation of the value passed to it, which might affect what gets assigned to a
?a
, but test c.getCount()
- are these two values actually the same? (see point 2). Also, is c.getCount()
still valid on the second call to it?}
missing somewhere - is the function actually following the path you think it is?Upvotes: 0
Reputation: 81660
put a space after WHERE:
"SELECT * FROM sharelist WHERE " + "category" + "=" + category,null
That should work.
Upvotes: 2