判断某张表是否存在

发布时间:2020-07-02 11:10:30 作者:曾颐楠
来源:网络 阅读:258
/**
         * 判断某张表是否存在
         * @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;
        }


推荐阅读:
  1. 判断临时表是否存在,存在就删除
  2. java如何判断数据库中是否存在某一张表

免责声明:本站发布的内容(图片、视频和文字)以原创、转载和分享为主,文章观点不代表本网站立场,如果涉及侵权请联系站长邮箱:is@yisu.com进行举报,并提供相关证据,一经查实,将立刻删除涉嫌侵权内容。

判断某张表是否存在 张表 某张

上一篇:android(基于监听)的事件处理

下一篇:怎么解决linux当前目录权限不够的问题

相关阅读

您好,登录后才能下订单哦!

密码登录
登录注册
其他方式登录
点击 登录注册 即表示同意《亿速云用户服务条款》