嗯,我有一个数据库,里面有很多表格.但一般情况下餐桌都是空的. 我想判断数据库表是否为空. 如果表为空,程序将填充它.
public static long queryNumEntries (SQLiteDatabase db, String table)
我会使用它,但它需要API 11.
嗯,我有一个数据库,里面有很多表格.但一般情况下餐桌都是空的. 我想判断数据库表是否为空. 如果表为空,程序将填充它.
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