Moshik
Moshik

Reputation: 589

SQLite, can't delete columns

UPDATE: See self-answer, "fixed, need to channge the where clauses"

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

Upvotes: 0

Views: 1139

Answers (3)

Diego Torres Milano
Diego Torres Milano

Reputation: 69368

Much better, forget about escaping quotes and other subtleties using

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

Upvotes: 2

f3lix
f3lix

Reputation: 29875

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

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

Upvotes: 3

Moshik
Moshik

Reputation: 589

fixed, need to channge the where clauses

Upvotes: 0

Related Questions