[android-developers]Why insert row into table return null?

2011-06-02 Thread Vicky Wang
Hi, all
When i want to insert one row into the table of database, i
use getContentResolver().insert(uri, contentvalues). But the return is null.
why? What error happed?
Thanks for your help.

Vicky

-- 
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

Re: [android-developers]Why insert row into table return null?

2011-06-02 Thread A. Elk
Some comments:

   1. You use getContentResolver().insert(uri,values) to insert a row into a 
   content provider. Please don't equate content provider = database. Though 
   many content providers are implemented as databases, it's not a requirement. 
   *In particular*, a database provides operations such as join that a 
   content provider is not required to implement.
   2. A null result from a content provider method *usually* indicates an 
   error. 
   In particular, the common pattern for query is to return null if an 
   internal error occurred (for example, an invalid URI). If no records match 
   the query, the common pattern is to return a Cursor with no records.
   3. Since you're getting null for insert, the first thing I'd check is 
   the URI value you're passing in.

A. Elk

-- 
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