Meryl Silverburgh wrote: > 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"); > }
Your table or content provider may not have a column named "x". Just because you pass such a value in the ContentValues on insert() does not mean it will get stored, if there is no pre-defined place to store it. -- Mark Murphy (a Commons Guy) http://commonsware.com | http://twitter.com/commonsguy _The Busy Coder's Guide to Android Development_ Version 2.0 Available! --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---