private static String DB_PATH = "/data/data/mypackage/databases/";
    private boolean checkDataBase(String DB){
 
     SQLiteDatabase checkDB = null;
 
     try{
      String myPath = DB_PATH + DB;
      checkDB = SQLiteDatabase.openDatabase(myPath, null, SQLiteDatabase.OPEN_READONLY);
      }catch(SQLiteException e){
      //database does't exist yet.
      }
 
     if(checkDB != null){
       checkDB.close();
      }
 
     return checkDB != null ? true : false;
    }
    
    /**
     * Copies your database from your local assets-folder to the just created empty database in the
     * system folder, from where it can be accessed and handled.
     * This is done by transfering bytestream.
     * */
    private void copyDataBase(String DB) throws IOException {
 
     //Open your local db as the input stream
     InputStream myInput = this.getAssets().open(DB);
 
     // Path to the just created empty db
     String outFileName = DB_PATH + DB;
 
     //Open the empty db as the output stream
     OutputStream myOutput = new FileOutputStream(outFileName);
 
     //transfer bytes from the inputfile to the outputfile
     byte[] buffer = new byte[1024];
     int length;
     while ((length = myInput.read(buffer))>0){
      myOutput.write(buffer, 0, length);
     }
 
     //Close the streams
     myOutput.flush();
     myOutput.close();
     myInput.close();
    }

위의 코드는 이클립스에서 data/data/mypackage/databases 폴더에 db 파일을 지워놓고
assets 에 db 를 두고.. 작업했을 때.. 정상 작동합니다. /databases 폴더 안에 db 파일이 없으니까.
assets 에 있는 db 를 복사해 오는거죠.

하지만, 단말기를 연결했을 경우,
첫번째, DDMS 에서 /data 밑에 아무 폴더도 보이지 않습니다... 처음 에뮬에서 작업할 때 처럼요.. 아마도.. 단말기도 에뮬에서 처럼
적어도 한번은 디비가 생성되어야 /data/data/..../databases 폴더가 생성되는거 아닌듯 싶네요....불길....

결국.. 처음 실행되었을 때... 더미 디비를 이용해서 이 폴더를 우회적으로 생성해 두고..
assets 에 있는 디비가 /databases 폴더에 없을 경우...위의 코드를 실행해야 한다는 의미겠네요.

지금 새벽 3시라..졸려서 더이상 작업하기 힘들어서...글을 남겨봅니다.... 혹시라도...다른 의견이 있을 것 같아서요.



그럼 이만.