2013-02-22 5 views
1

-> 좋아, 여기에 SD 카드에 Sq-lite 데이터베이스가있다.안드로이드의 외부 저장소에서 데이터베이스에 액세스하거나 엽니 다

(String DB_PATH = Environment.getExternalStorageDirectory().getPath().toString();) 

-> 데이터베이스가

 dbFile = new File(DB_PATH + DB_NAME); 
     if(dbFile.exists()== true) 
     { 
      //set text db exists 
      open_DB(); 

     } 
     else 
     { 
      //set text db does not exist 
      return; 
     } 

존재하는지 확인 - 내가 데이터베이스 파일의 존재를 확인할 수 디버깅>을.
데이터베이스를 열 때하지만 난 예외가

SQLiteDatabase checkDB = null; 
    try 
    { 
     dbFile = new File(DB_PATH + DB_NAME); 
     myDataBase = SQLiteDatabase.openOrCreateDatabase(dbFile, null); 

     //myDataBase = SQLiteDatabase.openDatabase(DB_PATH + DB_NAME, null, 0); 
     //also tried this 

     //set text bd opened 
    } 
    catch(SQLiteException e) 
    { 
     //set text bd unable open 
     return; 
    } 
+1

예외는 무엇입니까? –

답변

0

아마 문제가 플래그로 인해 발생 정도 이것을 사용하려고 정보 파일 수 :

dbFile = new File(DB_PATH + DB_NAME); 
if (dbFile.exists()) { 
    db = SQLiteDatabase.openDatabase(db_path, null, SQLiteDatabase.NO_LOCALIZED_COLLATORS | SQLiteDatabase.CREATE_IF_NECESSARY); 
} 

을 알려주세요.

관련 문제