데이터베이스의 백업을 성공적으로 만들었지 만 내 백업이 SDcard가 아닌 내부 메모리에 저장된다는 문제가 있습니다. 컨텍스트 클래스/SQLiteOpenHelper 클래스는 당신이 다른 곳 데이터베이스 파일하지만 내부 응용 프로그램 스토리지 .IE /data/data/com.you를 저장하지 않는 기본적으로SD 카드에서 데이터베이스 백업하는 방법
public void exportDatabase()
{
File sd = Environment.getExternalStorageDirectory();
File data = Environment.getDataDirectory();
String currentDBPath = "/data/" + "com.arpanexample.spm" + "/databases/" + Database.DATABASE_NAME;
String backupDBPath = Database.DATABASE_NAME;
File currentDB = new File(data, currentDBPath);
File backupDB = new File(sd, backupDBPath);
try {
FileChannel source = new FileInputStream(currentDB).getChannel();
FileChannel destination = new FileOutputStream(backupDB).getChannel();
destination.transferFrom(source, 0, source.size());
source.close();
destination.close();
Toast.makeText(context, "Successfully backup your data", Toast.LENGTH_LONG).show();
} catch (IOException e) {
e.printStackTrace();
}
}