判断数据库db中history_info表内容是否为空:
SQLite中的Cursor不能使用Cursor == null 来判断是否为空,
判断是否为空的方法是 通过Cursor.getCount()函数,得到的结果是0,表示Cursor为空;如果非0,则表示Cursor不为空。
代码如下
int amount=0;
Cursor c = db.rawQuery("select * from history_info", null);
amount=c.getCount();
amount为history_info中的项数,通过判断项数amount判断是否为空
本文介绍了一种在SQLite中判断数据库表内容是否为空的方法。通过使用Cursor.getCount()函数获取历史信息表history_info中的记录数量来判断表是否为空。如果返回的计数为0,则表示表为空。
7612





