Filenotfoundexception: /storage/emulated/0/android
I try this file writer/reader code segment for test: File file = new File(Environment.getExternalStorageDirectory(), 'LM/lm_lisdat_01.txt'); FileOutputStream outputStream = new Fil
Solution 1:
You are creating the file in one directory and trying to open it for input in another.
Environment.getExternalStorageDirectory()
is /storage/emulated/0
getExternalFilesDir(null)
is /storage/emulated/0/Android/data/hu.abisoft.lm/files
Use the same directory for file creation and input.
Solution 2:
With sdk, you can't write to the root of internal storage. This cause your error. Edit :
Based on your code, to use internal storage with sdk:
finalFiledir=newFile(context.getFilesDir() + "/nfs/guille/groce/users/nicholsk/workspace3/SQLTest");
dir.mkdirs(); //create folders where write filesfinalFilefile=newFile(dir, "BlockForTest.txt");
Solution 3:
Please see changes. Your path was wrong.
And also check whether file exists or not.
Filefile=newFile(Environment.getExternalStorageDirectory(), "LM/lm_lisdat_01.txt");
FileOutputStreamoutputStream=newFileOutputStream(file);
outputStream.write(("test").getBytes());
outputStream.close();
Filefile=newFile(Environment.getExternalStorageDirectory(), "LM/lm_lisdat_01.txt");//changes hereif(file.exists())
{
BufferedReaderbufferedReader=newBufferedReader(newInputStreamReader(newFileInputStream(file)));
}
Post a Comment for "Filenotfoundexception: /storage/emulated/0/android"