این متد یک Cursor بر می گردونه که حاوی تمام نتایج یافت شده در دیتابیس هست.
شما باید در این Cursor پیمایش کنید و نتایج رو نمایش بدید.
مثال:
public List<Article> getArticles() {
List<Article> articles = new ArrayList<Article>();
Cursor cursor = database.query("articles", new String[] { "title", "_id" }, null, null, null, null, null);
cursor.moveToFirst();
while (!cursor.isAfterLast()) {
String title = cursor.getString(0);
Integer id = cursor.getInt(1);
Article article = new Article();
article.setTitle(title);
article.setId(id);
articles.add(article);
cursor.moveToNext();
}
// Make sure to close the cursor
cursor.close();
return articles;
}
private static class Article {
private String title;
private int id;
public String getTitle() {
return title;
}
public void setTitle(String title) {
this.title = title;
}
public int getId() {
return id;
}
public void setId(int id) {
this.id = id;
}
}
الان این متد یک List بر میگردونه که اونو می تونید به ListView نسبت بدید تا نمایشش بده