不知道为什么,明明插进去了,但是就是查不到。既然cursor不为null了,count还是为0,getstring(index)也报错。求大神帮忙

解决方案 »

  1.   

    在这前面
    mCursor = managedQuery(mUri, PROJECTION, null, null, null);//查询
    重新
    Uri mUri = .....;
      

  2.   

    你确定ContentResolver的insert方法是返回的一个Uri类型吗?
      

  3.   

    Uri android.content.ContentResolver.insert(Uri url, ContentValues values)public final Uri insert (Uri url, ContentValues values) 
    Since: API Level 1 
    Inserts 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.
    确实是的
      

  4.   

    还是不行,insert后返回的uri是插入行的uri,我输出来看到是对的:content://beannote_note/note/10
      

  5.   

    insert后得到的uri面的10是行数,不是我的_id
      

  6.   

    看看你的provider怎么实现的,在解析这个uri的时候,是不是有问题,
      

  7.   

    String[],检索返回需要的字段
      

  8.   

    insert的时候是自己的provider。
    uri = ContentUris.withAppendedId(NOTEBOOK_URI, rowId)
    rowid是db.insert返回的数据行index。
    最后生成的是content://XXX/note/10。
    没有错误吧。。
      

  9.   

    我的意思是,你的query函数中,有没有正确的解析这个id
      

  10.   

    我知道了,managedQuery也得调用ContentResolver而且确实解析id有问题,谢谢你啦~