在SQLiteDatabase.openorcreate,这个方法可以满足你第一个要求,你看下api
第2个更简单了
拿到数据库对象后即为  SQLiteDatabase db = SQLiteDatabase.openorcreate(Data.db,XXX);
db.execSQL("if exists business");

解决方案 »

  1.   


    db.execSQL(String)返回值是void,请问怎么判断是否存在呢?
      

  2.   

    用SQLiteDatabase.openorcreate就可以解决第一个问题了!
      

  3.   

    判断是否存在库:
    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();
    }
    }有点失望