为什么不在这个代码工作 SQLiteOpenHelper
1个回答
展开全部
请尝试通过这种方式
private static final int DB_VERSION = 2; UPDATE HERE
public int getContactsCount() {
String countQuery = "SELECT * FROM " + TABLE_SOURCES;
SQLiteDatabase db = this.getReadableDatabase();
Cursor cursor = db.rawQuery(countQuery, null);
int count = cursor.getCount();
cursor.close();
// return count
return count;
}
private Database db = new Database(this);
Toast.makeText(this, String.valueOf(db.getContactsCount()),
Toast.LENGTH_LONG).show();
private static final int DB_VERSION = 2; UPDATE HERE
public int getContactsCount() {
String countQuery = "SELECT * FROM " + TABLE_SOURCES;
SQLiteDatabase db = this.getReadableDatabase();
Cursor cursor = db.rawQuery(countQuery, null);
int count = cursor.getCount();
cursor.close();
// return count
return count;
}
private Database db = new Database(this);
Toast.makeText(this, String.valueOf(db.getContactsCount()),
Toast.LENGTH_LONG).show();
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询