• 判断某张表是否存在


    /**
             * 判断某张表是否存在
             * @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;
            }

    本文出自 “曾颐楠的播客” 博客,请务必保留此出处http://zengyinan.blog.51cto.com/9524976/1721467

  • 相关阅读:
    2019高考数学理科Ⅱ卷解析版[解答题]
    对风说爱你
    佛教人生-伴侣
    【Echarts每天一例】-1
    算法中涉及的专业英语
    python--随机函数(random,uniform,randint,randrange,shuffle,sample)
    【linux shell系列--1】crontab命令
    【Python爬虫实战--3】html写正则表达式
    mysql启动参数 skip-grant-tables
    php通过反射执行某方法
  • 原文地址:https://www.cnblogs.com/zengyinanos/p/5042738.html
Copyright © 2020-2023  润新知