Possible Duplicate:
Moving my db to sd card not working내가 내 SDCARD에 sqlite가 파일을 저장하기 위해 노력하고있어
sdcard에하는 SQLite는 DB를 저장하려고합니다. 나는이 매우 높은 평가 대답이 question
try {
File sd = Environment.getExternalStorageDirectory();
File data = Environment.getDataDirectory();
if (sd.canWrite()) {
String currentDBPath = "\\data\\com.test.mytest\\databases\\test_db";
String backupDBPath = "test_db";
File currentDB = new File(data, currentDBPath);
File backupDB = new File(sd, backupDBPath);
if (currentDB.exists()) {
FileChannel src = new FileInputStream(currentDB).getChannel();
FileChannel dst = new FileOutputStream(backupDB).getChannel();
dst.transferFrom(src, 0, src.size());
src.close();
dst.close();
}
}
} catch (Exception e) {
}
에서 코드를 사용하고, 그래서 그것을 꽤 단순히 작동해야한다고 생각합니다. 나는 logcat에서 오류가 발생하지 않습니다. 내가 만든 디렉토리/생성 된 파일이 보이지 않습니다. 또한 내 매니페스트에 "외부에 쓰기"권한이 있습니다.
단순히 예외를 잡는 대신 예외를 기록하여 시작하십시오. 물론 catch (Exception e) {}'는 로그에 아무 것도 없습니다. – njzk2
작업 중간에 오류가 발생하면 오류로 기록되지 않습니까? – EGHDK
예외가 발생했을 때 catch 블록에 의해 catch되고 catch 블록이 비어 있으므로 아무 것도 수행되지 않습니다. 적어도 e.printStackTrace()를 넣으십시오. – njzk2