获得从SQLite的所有行 [英] Get all rows from SQLite
本文介绍了获得从SQLite的所有行的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我一直在试图让所有行从SQLite数据库。但是,我从以下codeS只有最后一排。
I have been trying to get all rows from the sqlite database. But I got only last row from the following codes.
文件选择器类:
public ArrayList<String> readFileFromSQLite() {
fileName = new ArrayList<String>();
fileSQLiteAdapter = new FileSQLiteAdapter(FileChooser.this);
fileSQLiteAdapter.openToRead();
cursor = fileSQLiteAdapter.queueAll();
if (cursor != null) {
if (cursor.moveToFirst()) {
do {
fileName.add(cursor.getString(cursor
.getColumnIndex(FileSQLiteAdapter.KEY_CONTENT1)));
} while (cursor.moveToNext());
}
cursor.close();
}
fileSQLiteAdapter.close();
return fileName;
}
FileSQLiteAdapter类:
public Cursor queueAll() {
String[] columns = new String[] { KEY_ID, KEY_CONTENT1 };
Cursor cursor = sqLiteDatabase.query(MYDATABASE_TABLE, columns, null,
null, null, null, null);
return cursor;
}
请告诉我哪里是我的不正确。鸭preciate。
Please tell me where is my incorrect. Appreciate.
推荐答案
尝试
Cursor cursor = db.rawQuery("select * from table",null);
和的名单,其中,字符串&GT;
if (cursor .moveToFirst()) {
while (cursor.isAfterLast() == false) {
String name = cursor.getString(cursor
.getColumnIndex(countyname));
list.add(name);
cursor.moveToNext();
}
}
这篇关于获得从SQLite的所有行的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文