您的位置:首页 > 移动开发 > Android开发

Android的SQLite中如何判断一个表是否存在

2015-08-14 14:49 876 查看
具体代码如下:(判断deviceinfo表是否存在)

public boolean isTableExists(SQLiteDatabase db) {

        String sql = "select count(*) as c from sqlite_master where type ='table' and name ='DeviceInfo';";

        cursor = db.rawQuery(sql, null);

        if (cursor.moveToNext()) {

            int count = cursor.getInt(0);

            if (count > 0) {

                result = true;

            }

        }

        return result;

    }
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: