我使用 SQLiteQueryBuilder 使用以下代码从我的数据库中查询信息
SQLiteQueryBuilder builder = new SQLiteQueryBuilder();
builder.setTables("customers");
Cursor cursor = builder.query(database, null, null, null, null, null, null);
但我没有收到光标中的任何元素
我确信数据库中有数据
我的代码有什么问题?
我使用 SQLiteQueryBuilder 使用以下代码从我的数据库中查询信息
SQLiteQueryBuilder builder = new SQLiteQueryBuilder();
builder.setTables("customers");
Cursor cursor = builder.query(database, null, null, null, null, null, null);
但我没有收到光标中的任何元素
我确信数据库中有数据
我的代码有什么问题?
It's hard to determine from what you've placed, but the most likely is the previous query you posted.
final static String CUSTOMERS_TABLE = "customers";
database.rawQuery("select * from CUSTOMERS_TABLE", null);
If this is what your code actually is, you need to concatenate your query with the constant, otherwise you will get no results because CUSTOMERS_TABLE
doesn't exist, but customers
does.
Something like this
final static String CUSTOMERS_TABLE = "customers";
database.rawQuery("select * from " + CUSTOMERS_TABLE, null);
Be careful here
"select * from CUSTOMERS_TABLE"
"select * from customers"
If you're still getting no results, you may actually have no data. Make sure to check that as well.