0

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

3 Answers 3

3

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

getContentResolver().delete(myUri, "NAME='chris'", null);
Sign up to request clarification or add additional context in comments.

1 Comment

Could you explain why? Thank you very much.
2

Much better, forget about escaping quotes and other subtleties using

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

Comments

0

fixed, need to channge the where clauses

1 Comment

Why don't you correctly close your question or tag answer 1 or 2 as the correct answers?

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.