Reputation: 143
public void AddViewCount(String chname)
{
String selectQuery = "UPDATE channel_login SET TimesViewed=TimesViewed+1 WHERE channelName="+chname ;
SQLiteDatabase db = this.getWritableDatabase();
Cursor cursor = db.rawQuery(selectQuery, null);
System.out.print("Count"+cursor.getCount());
}
I m getting this error message. Can you please point out the culprit?
android.database.sqlite.SQLiteException: no such column: Sat1
(code 1):,while compiling: UPDATE channel_login SET
TimesViewed=TimesViewed+1 WHERE channelName=Sat1
Upvotes: 1
Views: 2767
Reputation: 8747
Try the following:
public void AddViewCount(String chname)
{
String selectQuery = "UPDATE channel_login SET TimesViewed=TimesViewed+1 WHERE channelName='"+chname+"'";
SQLiteDatabase db = this.getWritableDatabase();
Cursor cursor = db.rawQuery(selectQuery, null);
System.out.print("Count"+cursor.getCount());
}
Adding the ' ' around the text value should work. Also, unless you need the cursor count, you could just use db.execSQL(selectQuery);
to perform the update.
Upvotes: 3