Wednesday, January 22, 2014

About query the database to return cursor! = Null but getcount 0 problems.


 
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:
reference to the third floor of the reply:
you sure ContentResolver insert method returns a Uri type it?

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:
reference to the second floor of the reply:
in front
mCursor = managedQuery (mUri, PROJECTION, null, null, null) ;/ / query
Re
Uri mUri = .....;

Or not, the insert is inserted into the return line uri uri, I saw a pair of outputs: content :/ / beannote_note/note/10
Reply:
reference to the second floor of the reply:
in front
mCursor = managedQuery (mUri, PROJECTION, null, null, null) ;/ / query
Re
Uri mUri = .....;

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:
reference to the 7th floor of replies:
PROJECTION what

String [], retrieved returns required fields
Reply:
referenced 8th Floor reply:
look at your provider how to achieve, when parsing the uri is not a problem,
< / fieldset>
insert when their own provider.
uri = ContentUris.withAppendedId (NOTEBOOK_URI, rowId)
rowid is db.insert returned rows index.
Last generation is content :/ / XXX/note/10.
No error bars. .

Reply:
I mean, your query function, there is no correct parse this id
Reply:
reference to the 11th floor of the reply:
I mean, your query function, there is no correct parse this id

I use managedQuery
Reply:
reference to the 11th floor of the reply:
I mean, your query function, there is no correct parse this id

I know, managedQuery have to call ContentResolver. . . Id have to resolve the issue and indeed, thank you very much ~
Reply:
The landlord how to solve, I have encountered similar problems
Reply:
I also encountered a similar problem in general how to see how to find?

No comments:

Post a Comment