안드로이드 개발 질문/답변
(글 수 45,052)
Context 클래스가 아닌 클래스에서 아래와 같이 파일을 저장하기위해 코딩을 했습니다.
빨간줄로 쳐있는 부분을 Context 클래스에서 값을 전달받아 사용하였는데 파일이 형성되지 않습니다.
다른 방법이 있을까요?
try{
File file = new File("test.png");
FileOutputStream fos = _context.openFileOutput("test.png" , 0);
bm.compress(CompressFormat.PNG, 100 , fos);
fos.flush();
fos.close();
}catch(Exception e) {
Toast.makeText(this, "file error", Toast.LENGTH_SHORT).show();
}