what i want to do is do a search of my database for a string then find out what the row id is where that string is.
I thought by doing this
    public void getRow(){
    ContactDB db = new ContactDB(this);
    db.open();
    Cursor c = db.getId("1234567890");
    String test = c.getString(c.getColumnIndex(db.PHONE_NUMBER));
    Log.v("Contact", "Row ID: " + test);
    db.close();
database class
public Cursor getId(String where){
    return db.query(DATABASE_TABLE, new String[] {ID},where,null,null,null,null);
}
that it would give me what i want but i get a "cursor index out of bounds" error, how should i be doing 开发者_运维百科this?
change getId to:
     public Cursor getId(String where){
        Cursor c = db.query(DATABASE_TABLE, new String[] {ID},where,null,null,null,null);
        if (c != null) c.moveToFirst();
        return c;
     }
You need to do c.moveToFirst() before tying to read any information.
Also do c.close() when you're done.
 
         
                                         
                                         
                                         
                                        ![Interactive visualization of a graph in python [closed]](https://www.devze.com/res/2023/04-10/09/92d32fe8c0d22fb96bd6f6e8b7d1f457.gif) 
                                         
                                         
                                         
                                         加载中,请稍侯......
 加载中,请稍侯......
      
精彩评论