How in android to display in ListView only one line from a database? What request can is on _id or still something?

Closed due to the fact that it is necessary to reformulate the question so that it was possible to give an objectively correct answer by the participants Denis Bubnov , user194374, rjhdby , Mikhail Vaysman , Akina 16 Feb '17 at 16:33 .

The question gives rise to endless debates and discussions based not on knowledge, but on opinions. To get an answer, rephrase your question so that it can be given an unambiguously correct answer, or delete the question altogether. If the question can be reformulated according to the rules set out in the certificate , edit it .

  • one
    What exactly you can not. Make a query in SQL, get this line on request, display the resulting line in the list or something else? What you have tried to do and an example of your failed attempts. - pavlofff
  • I know how to query the column, and how to query the string? - Alexey
  • That is, your problem is that you cannot make a request to get the entire row by ID. So you need to write in the question. The more complete it is, the faster and more qualitatively you can get a solution. - pavlofff

1 answer 1

 long id = 10; Cursor cursor = db.query(("table name", null, "_id = ?", new String[] {Long.toString(id)}, null, null, null); // или упрощенная запись (не рекомендуется) // Cursor cursor = db.query(("table name", null, "_id = " + id, null, null, null, null); cursor.moveToFirst(); 

the cursor will contain all the columns for the row in the table table name , _id of which = 10 and the cursor pointer will be positioned on this row.

More query writing examples