如何从数据库中获取选定的值

时间:2011-10-12 06:30:48

标签: android sqlite

我只希望表格数据库中的选定值取决于i和j?

public Cursor getAll() {
         int i=2;j=1;  
           return (getReadableDatabase().rawQuery(
                        "SELECT _id,note,answer From Notes where _id=? AND note=?",new String[]{i+""},new String[]{j+""}));
        }

1 个答案:

答案 0 :(得分:0)

试试这个。

public Cursor getAll() {
   int i=2;
   return (getReadableDatabase().rawQuery(
                "SELECT _id,note,answer From Notes where _id=? ",new String[]{i+""}));
}

对于多个参数......

public Cursor getAll() {
     int i=2;j=1;  
       return (getReadableDatabase().rawQuery(
                    "SELECT _id,note,answer From Notes where _id=? AND note=?",new String[]{i+"", j+""}));
    }