Android column '_id' does not exist?

前端 未结 8 864
野性不改
野性不改 2020-11-22 15:39

I\'m having trouble with something that works in the Notepad example. Here\'s the code from the NotepadCodeLab/Notepadv1Solution:

String[] from = new String[         


        
相关标签:
8条回答
  • 2020-11-22 16:06

    Tim Wu's code really works...

    If you are using db.query, then it would be like this...

    db.query(TABLE_USER, new String[] { 
                    "rowid _id",
                    FIELD_USERNAME,
                    }, 
                    FIELD_USERNAME + "=" + name, 
                    null, 
                    null, 
                    null, 
                    null);
    
    0 讨论(0)
  • 2020-11-22 16:11

    Another way of dealing with the lack of an _id column in the table is to write a subclass of CursorWrapper which adds an _id column if necessary.

    This has the advantage of not requiring any changes to tables or queries.

    I have written such a class, and if it's of any interest it can be found at https://github.com/cmgharris/WithIdCursorWrapper

    0 讨论(0)
提交回复
热议问题