res폴더에 들어있는 이미지나, 동영상 등등의 파일을
sd카드로 이동하는 것이 가능한가요?
가능하다면 조언 부탁드립니다^^
감사합니다~
getResources().openRawResource(int id) 로 InputStream을 얻어와서
읽은 것 그대로 파일로 쓰면 될 것 같네요.
public void setFile()
{
File outfile = new File(Environment.getExternalStorageDirectory(),SLASH + FOLDER_NAME);
InputStream is = null;
FileOutputStream fo = null;
long filesize = 0;
try {
is = getResources().openRawResource(R.raw.ocean_seagull);
filesize = is.available(); //--사이즈 검증
if (outfile.length() <= 0) {
byte[] tempdata = new byte[(int) filesize];
is.read(tempdata);
is.close();
outfile.createNewFile();
fo = new FileOutputStream(outfile);
fo.write(tempdata);
fo.close();
}
else
{
}
} catch (IOException e) {
Toast.makeText(this, "실패", Toast.LENGTH_LONG).show();
}
}
위와 같이 짜보았는데 is.read에서 read가 안되네요ㅠㅠ
잘못짠건가요ㅠ
파일쓰기를 이용하면 될 듯 한데...
res/raw에 있는 파일 경로는 어떻게 써주어야 하나요?ㅠㅠ