Android SQLite SELECT Query

后端 未结 6 1290
我寻月下人不归
我寻月下人不归 2020-12-30 00:03

I have taken String value from a EditText and set it inside SELECT QUERY after WHERE condition

As

TextView tv          


        
6条回答
  •  南笙
    南笙 (楼主)
    2020-12-30 00:36

    Try using the following statement:

    Cursor c = db.rawQuery("SELECT * FROM tbl1 WHERE name = ?", new String[] {name});

    Android requires that WHERE clauses compare to a ?, and you then specify an equal number of ? in the second parameter of the query (where you currently have null).

    And as Nambari mentioned, you should use c.moveToFirst() rather than c.moveToNext()

    Also, could there be quotations in name? That could screw things up as well.

提交回复
热议问题