判断某张表是否存在
更新:HHH   时间:2023-1-7


/**
         * 判断某张表是否存在
         * @param tabName 表名
         * @return
         */
        public boolean tabIsExist(String tabName){
                boolean result = false;
                if(tabName == null){
                        return false;
                }
                SQLiteDatabase db = null;
                Cursor cursor = null;
                try {
                        db = this.getReadableDatabase();//此this是继承SQLiteOpenHelper类得到的
                        String sql = select count(*) as c from sqlite_master where type ='table' and name ='+tabName.trim()+' ;
                        cursor = db.rawQuery(sql, null);
                        if(cursor.moveToNext()){
                                int count = cursor.getInt(0);
                                if(count>0){
                                        result = true;
                                }
                        }
                         
                } catch (Exception e) {
                        // TODO: handle exception
                }                
                return result;
        }


返回开发技术教程...