public boolean tabIsExist(String tabName){
boolean result = false;
if(tabName == null){
return false;
}
Cursor cursor = null;
try {

String sql = "select count(*) as c from sqlite_master where type ='table' and name ='"+tabName.trim()+"' ";
cursor = dbInfo.rawQuery(sql, null);
if(cursor.moveToNext()){
int count = cursor.getInt(0);
if(count>0){
result = true;
}
}

} catch (Exception e) {
// TODO: handle exception
}
return result;
}

对sqlite_master表查询不但可以得到建表的sql语句,还可以获取该数据库内的trigger信息

而在纯java环境下对SQL数据库查询是否目标表格存在的时候可以更简单:

java.sql.Connection con = getYourConnection();

ResultSet rs = con.getMetaData().getTables(null, null, "yourTable", null );
if (rs.next()) {
//yourTable exist
}else {
//yourTable not exist
}

更多相关文章

  1. 【简单的学生管理界面】Android的if语句中有字符串判断
  2. FlycoDialog_Master 强大的Android对话框库内置常用Dialog
  3. Android Sqlite数据库中判断某个表是否存在的SQL语句
  4. android常用语句
  5. Android Studio module里面放switch语句报错 R文件找不到
  6. Android SDK 5.0 这个语句带来折腾 - 生命在于折腾!
  7. Android中的那些sql语句
  8. Android怎么在控制台输出语句

随机推荐

  1. 图片处理
  2. Security and Permissions 安全与权限 (一
  3. Android(安卓)Studio通过style和layer-li
  4. android的fragment使用中static静态fragm
  5. Android自定义系统分享面板
  6. Android(安卓)Java(2015-6-18 15:28、2016
  7. 软键盘问题汇总
  8. Android(安卓)内存泄漏 - Animator的使用
  9. android上一些类型转换
  10. Android——GridView