在SQLiteDatabase.openorcreate,这个方法可以满足你第一个要求,你看下api
第2个更简单了
拿到数据库对象后即为 SQLiteDatabase db = SQLiteDatabase.openorcreate(Data.db,XXX);
db.execSQL("if exists business");
第2个更简单了
拿到数据库对象后即为 SQLiteDatabase db = SQLiteDatabase.openorcreate(Data.db,XXX);
db.execSQL("if exists business");
解决方案 »
- 界面设计问题
- ❤❤❤我不会写应用,竟然要我写Android远程协助,哭、要怎么写呢?❤❤❤
- 请教while 循环 与界面交互的问题。谢谢。
- Android SDK 1.5 是不是不能使用 AlertDialog.Builder
- Android:如何从网页源码中提取所需要内容?
- android拍照程序的问题
- Eclipse的Navigator栏中是否可以新建一个文件夹,对项目进行归类
- 极光推送技术不就是简单的TCP/IP协议监听吗?
- eclipse 报这个错误
- 当手机使用USB连接PC以后,不让PC成识别手机设备,而是识别成打印机设备?
- 请教!在android上如何让bluetooth休眠的问题
- 请教一个VideoView的问题
db.execSQL(String)返回值是void,请问怎么判断是否存在呢?
File dbFile = getDatabasePath(DBUtil.DB_NAME);
if(dbFile.exists() == true){
SodinoOut.out("DB_NAME Exist");
} else {
SodinoOut.out("DB_NAME DOES NOT Exist");
}
判断库中是否存在表
String sql = "select * from sodino";
Cursor cursor = null;
try {
cursor = sqlDb.rawQuery(sql, null);
if(cursor != null){
SodinoOut.out("Exist table :sodino");
}else{
SodinoOut.out("<else>DO NO Exist table :sodino");
}
} catch (SQLiteException e) {
SodinoOut.out(e.toString());
SodinoOut.out("<catch>DO NO Exist table :sodino");
} finally {
if (cursor != null) {
cursor.close();
}
}有点失望