加入收藏 | 设为首页 | 会员中心 | 我要投稿 李大同 (https://www.lidatong.com.cn/)- 科技、建站、经验、云计算、5G、大数据,站长网!
当前位置: 首页 > 百科 > 正文

sqlite 判断某张表是否存在

发布时间:2020-12-12 20:15:17 所属栏目:百科 来源:网络整理
导读:/** *判断某张表是否存在 *@paramtabName表名 *@return */ public boolean tabbleIsExist(StringtableName){ boolean result= false ; if (tableName== null ){ return } SQLiteDatabasedb= null ; Cursorcursor= try { db= this .getReadableDatabase(); St
  1. /**
  2. *判断某张表是否存在
  3. *@paramtabName表名
  4. *@return
  5. */
  6. publicbooleantabbleIsExist(StringtableName){
  7. booleanresult=false;
  8. if(tableName==null){
  9. return }
  10. SQLiteDatabasedb=null;
  11. Cursorcursor=try{
  12. db=this.getReadableDatabase();
  13. Stringsql="selectcount(*)ascfromSqlite_masterwheretype='table'andname='"+tableName.trim()+"'";
  14. cursor=db.rawQuery(sql,null);
  15. if(cursor.moveToNext()){
  16. intcount=cursor.getInt(0);
  17. if(count>0){
  18. result=true;
  19. }catch(Exceptione){
  20. //TODO:handleexception
  21. returnresult;
  22. }

(编辑:李大同)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!

    推荐文章
      热点阅读