在Android 2.2上创建新的数据库之前,我需要检查现有的数据库。如何检查?

最佳答案

使用openOrCreateDatabase方法
Read here
----编辑----

public boolean checkDataBase(){

    SQLiteDatabase checkDB = null;

    try{
        String myPath = DB_PATH + DB_NAME;
        checkDB = SQLiteDatabase.openDatabase(myPath, null, SQLiteDatabase.OPEN_READONLY | SQLiteDatabase.NO_LOCALIZED_COLLATORS);

    }catch(SQLiteException e){

        //database does't exist yet.
    }

    if(checkDB != null){
        checkDB.close();
    }

    return checkDB != null ? true : false;
}

07-24 09:26