애뮬에서 텍스트를 생성하고 저장하고 싶은데 계속 FileNotFoundExcpetion이 발생합니다.
실물 안드로이드폰에서는 잘 실행되는데 애뮬에서는 안됩니다. 도와주세요.
public void saveText() {
try {
String path = Environment.getExternalStorageDirectory()+"/serial";
File file = new File(path);
if(!file.exists())
file.mkdirs();
file = new File(file,"data.txt");
FileOutputStream fileOutputStream = new FileOutputStream(file,true);
String msg ="테스트용 파일입니다.";
fileOutputStream.write(msg.getBytes());
fileOutputStream.close();
Toast.makeText(this, "Save Success", Toast.LENGTH_LONG).show();
}catch (FileNotFoundException fnfe){
Toast.makeText(this,"지정된 파일을 생성할 수 없습니다.",Toast.LENGTH_LONG).show();
}catch (IOException ioe) {
Toast.makeText(this, "파일에 데이터를 쓸 수 없습니다.", Toast.LENGTH_SHORT).show();}
}