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();
String sql = "select count(*) as c from sqlite_master 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;
}
总结
如果觉得编程之家网站内容还不错,欢迎将编程之家网站推荐给程序员好友。
本图文内容来源于网友网络收集整理提供,作为学习参考使用,版权属于原作者。
如您喜欢交流学习经验,点击链接加入交流1群:1065694478(已满)交流2群:163560250