0
public ArrayList < PatientInfo > getAllPatients(String username) {
    ArrayList < PatientInfo > patients = new ArrayList < PatientInfo > ();

    open();

    Cursor cursor = db.query(UserTable, null, null, null, null, null, AccessedDate);
    while (cursor != null && cursor.moveToNext()) {
        try {

        } catch (Exception ex) {
            //Log.e("XXX", ex.getMessage());
        }
    }
    if (cursor != null)
        cursor.close();
    close();

    Collections.reverse(patients);
    return patients;
}

メソッドの引数としてユーザー名を取得しています。ユーザー名に基づいてテーブルを照会し、user specific result.

4

1 に答える 1

2

ドキュメントからわかるように、3 番目と 4 番目のパラメータquery()は選択と選択の引数です。

したがって、次のようなものが必要です。

 Cursor cursor = db.query(UserTable, null, 
                          "username=?", new String[] {username}, 
                          null, null, AccessedDate);

テーブル内の関連する列の実際の名前と一致するように、必要に応じて 3 番目のパラメーターを編集します。

于 2013-05-01T21:23:20.277 に答える