开发者

Why can't I delete using a getContentResolver..?

开发者 https://www.devze.com 2023-01-25 04:20 出处:网络
I can get the data with NO problem...but I cannot delete the data. Any Suggestions..?? Cursor cu = getContentResolver().query(CONTENT_URI, null, null, null, null);

I can get the data with NO problem...but I cannot delete the data. Any Suggestions..??

                Cursor cu = getContentResolver().query(CONTENT_URI, null, null, null, null);
            if (cu.moveToFirst())
            {
                numberInDb = cu.getString(2);
                System.out.println("Number in DB = " + numberInDb);
            }

            ContentResolver c = getContentResolver();

NEITHER OF THESE NEXT 2 LINES WORK

            c.delete(CONTENT_URI, "TIT开发者_如何学JAVALE ="+ numberInDb, null);
            getContentResolver().delete(CONTENT_URI, "TITLE ="+ numberInDb, null);


If TITLE is a string, I suspect that you need to quote it in your query:

getContentResolver().delete(CONTENT_URI, "TITLE ='" + numberInDb + "'", null)

Also, check the logcat output and see if there are any SQLite errors.

0

精彩评论

暂无评论...
验证码 换一张
取 消