tags:

views:

236

answers:

3

Hi, i have set a content provider, for some reason I am able to to delete a row this way:

getContentResolver().delete(myUri, "_id=" + "3", null);

but i am not able to delete a row that way:

getContentResolver().delete(myUri, "NAME=" + "chris", null);

getting this error:

02-15 15:48:08.197: ERROR/AndroidRuntime(3043): android.database.sqlite.SQLiteException: no such column: chris: , while compiling: DELETE FROM User WHERE NAME=chris


I have checked my database file, and it is there.. but for some reason i can delete columns from my database only by the _id column,

how can i fix this?

error:

02-15 15:48:08.197: ERROR/AndroidRuntime(3043): android.database.sqlite.SQLiteException: no such column: idanmoshik1: , while compiling: DELETE FROM User WHERE USER_NAME=idanmoshik1

*User is the name of my table.

thanks,

Moshik

A: 

fixed, need to channge the where clauses

Moshik
Why don't you correctly close your question or tag answer 1 or 2 as the correct answers?
Zordid
+3  A: 

You should add single quotes (') around chris and idanmoshik1 like this

getContentResolver().delete(myUri, "NAME='chris'", null);
f3lix
+1  A: 

Much better, forget about escaping quotes and other subtleties using

final int n = getContentResolver().delete(myUri, "NAME = ?", new String[] {"user's name"});
dtmilano