Thank you.

I have another question about cursor.

I have inserted a ContentValue like this:
  final ContentResolver cr = context.getContentResolver();

  ContentValue values = new ContentValues();
 values.put("title", "new title");
  values.put("x", 10);

  Uri result = cr.insert(CONTENT_URI ,
                values);

But why when I do my query and then getColumn, I get
 java.lang.IllegalArgumentException: column 'x' does not exist

   Cursor c = cr.query(CONTENT_URI,
            new String[] { "title" }, "title=?",
            new String[] { "new title" }, null);

  if (c.getCount() >0) {
     // get an exception here:
       int xColumn = c.getColumnIndexOrThrow("x");
  }

On Fri, Apr 24, 2009 at 3:03 PM, Mark Murphy <mmur...@commonsware.com> wrote:
>
> Meryl Silverburgh wrote:
>> Hi,
>>
>> I call ContentResolver's query method to get a Cursor, and I would
>> like to update the title of that row to 'new title'
>> can you please tell me how to do it?
>>
>> final ContentResolver cr = context.getContentResolver();
>>  Cursor c = cr.query(MY_CONTENT_URI,
>>             new String[] { "title"}, "title=?",
>>             new String[] { title }, null);
>>
>> if (c.getCount() > 0) {
>>  // want to update the title to 'new title'
>>
>> }
>
> context.getContentProvider().update()
>
> There is no update() method on Cursor.
>
> --
> Mark Murphy (a Commons Guy)
> http://commonsware.com | http://twitter.com/commonsguy
>
> Android App Developer Books: http://commonsware.com/books.html
>
> >
>

--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google
Groups "Android Developers" group.
To post to this group, send email to android-developers@googlegroups.com
To unsubscribe from this group, send email to
android-developers-unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to