안드로이드 개발 질문/답변
(글 수 45,052)
위와 같은 파일을 Intro 로딩후에 sd카드에 설치하고 싶은데.. 계속 카피 에러가 뜨네여 .. 소스는 아래와 같습니다.
어디가 잘못 됐는지 모르겠네여..
protected void copyMp3() {
// TODO Auto-generated method stub
try {
// 앱 접근 DB 위치
final File f = new File(
"/data/data/패키지명/audio/free1.mp3");
final File f2 = new File("/data/data/패키지명/audio");
if(!f2.exists())
f2.mkdir();
if (!f.exists()) {
//f.delete();
f.createNewFile();
// am = this.getResources().getAssets(R.raw.);
for (int i = 0; i < arrIs.length; i++){
// 테스트 mp3 파일 위치
arrIs[i] = am.open("audio/free1.mp3");
arrBis[i] = new BufferedInputStream(arrIs[i]);
}
fos = new FileOutputStream(f);
bos = new BufferedOutputStream(fos);
int read = -1;
final byte[] buffer = new byte[1024];
// 복사
for (int i = 0; i < arrIs.length; i++) {
while ((read = arrBis[i].read(buffer, 0, 1024)) != -1) {
bos.write(buffer, 0, read);
}
bos.flush();
}
// 성공
Log.i("MyLog", "mp3 copy success~~..");
} else {
Log.i("MyLog", "exist mp3!!");
}
} catch (Exception e) {
// 실패
Log.i("MyLog", "mp3 copy fail!!...");
}
}



혹시 퍼미션에 외장메모리에 쓰는 권한을 추가하셨는지 확인해보세요.