당신은 대부분의 디바이스 제조에 의해 선택이
private void exportDB(){
File sd = Environment.getExternalStorageDirectory();
File data = Environment.getDataDirectory();
FileChannel source=null;
FileChannel destination=null;
String currentDBPath = "/data/"+ "com.your.package" +"/databases/"+db_name;
String backupDBPath = SAMPLE_DB_NAME;
File currentDB = new File(data, currentDBPath);
File backupDB = new File(sd, backupDBPath);
try {
source = new FileInputStream(currentDB).getChannel();
destination = new FileOutputStream(backupDB).getChannel();
destination.transferFrom(source, 0, source.size());
source.close();
destination.close();
Toast.makeText(this, "DB Exported!", Toast.LENGTH_LONG).show();
} catch(IOException e) {
e.printStackTrace();
}
}
공유 환경 설정 파일 위치와 같은 sdcard에 당신의 SQLite는 DB를 복사 할 수 있습니다, 그래서 공유 된 환경 설정 파일의 하드 코드 경로에 좋지 않다.
우수 답변 : http://stackoverflow.com/a/18322762/1318946 –