好吧,我有一个数据库,里面有很多桌子。但通常表是空的。我想检查数据库表是否为空。如果表为空,程序将填充它。
public static long queryNumEntries (SQLiteDatabase db, String table)
我将使用它,但它需要API 11。
您可以执行select count(*) from table
并检查是否count> 0
保留其他内容。
喜欢
SQLiteDatabase db = table.getWritableDatabase();
String count = "SELECT count(*) FROM table";
Cursor mcursor = db.rawQuery(count, null);
mcursor.moveToFirst();
int icount = mcursor.getInt(0);
if(icount>0)
//leave
else
//populate table
本文收集自互联网,转载请注明来源。
如有侵权,请联系[email protected] 删除。
我来说两句