mUri = getContentResolver (). insert (mUri, values) ;/ / has been successfully inserted into the database, see the
in the databasemCursor = managedQuery (mUri, PROJECTION, null, null, null) ;/ / query
if (mCursor! = null) {
Log.i (LOG_TAG, Integer.toString (mCursor.getCount ())) ;/ / / / / / / / / / / / / Data result is 0
if (! mCursor.moveToFirst ())
{
Log.i (LOG_TAG, "MCursor movetofirst failed ....") ;/ / / / / / / / / / / / / display failed
}
String note = mCursor.getString (0) ;/ / error: android.database.CursorIndexOutOfBoundsException: Index 0 requested, with a size of 0
}
Reply:
I do not know why, obviously insert, but is finding out. Since the cursor is not null, count or is 0, getstring (index) is also given. Great God seeking help
Reply:
In front
mCursor = managedQuery (mUri, PROJECTION, null, null, null) ;/ / query
Re
Uri mUri = .....;
Reply:
Are you sure ContentResolver insert method returns a Uri type it?
Reply:
Uri android.content.ContentResolver.insert (Uri url, ContentValues values)
public final Uri insert (Uri url, ContentValues values)
Since: API Level
1Inserts a row into a table at the given URL. If the content provider supports transactions the insertion will be atomic.
Parameters
url The URL of the table to insert into.
values The initial values for the newly inserted row. The key is the column name for the field. Passing an empty ContentValues will create an empty row.
Returns
the URL of the newly created row.
Yes indeed
Reply:
Or not, the insert is inserted into the return line uri uri, I saw a pair of outputs: content :/ / beannote_note/note/10
Reply:
After insert the resulting uri surface 10 is the number of rows, not my _id
Reply:
What is PROJECTION
Reply:
Look at your provider how to achieve, when parsing the uri is not a problem,
Reply:
String [], retrieved returns required fields
Reply:
No comments:
Post a Comment