zoukankan      html  css  js  c++  java
  • android sqlite中判断某个表是否存在

    <span style="font-size:18px;">sqlite 中判断某个表是否存在的方法,贴出来供大家参考
    /**
         * 判断某张表是否存在
         * @param tabName 表名
         * @return
         */
        public boolean tabbleIsExist(String tableName){
                boolean result = false;
                if(tableName == null){
                        return false;
                }
                SQLiteDatabase db = null;
                Cursor cursor = null;
                try {
                        db = this.getReadableDatabase();
                                                               //这里表名可以是Sqlite_master
                        String sql = "select count(*) as c from "+AppConstant.DataBaseName+" where type ='table' and name ='"+tableName.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;
        }</span>

  • 相关阅读:
    h5-7
    h5-6
    h5-5
    h5-4
    h5-3
    h5-2
    return
    字符串的常用操作
    字符串中的转义字符
    字典的统计,合并,清空操作
  • 原文地址:https://www.cnblogs.com/sharecenter/p/5621066.html
Copyright © 2011-2022 走看看