Reputation: 1141
My application creates a text file. I want that users to have easy access to these files. I write this text file them on the sdcard. I want to allow users to edit the file with other programs.
I see these files using the File Explorer, but I can not see using file manager.
String extPath = Environment.getExternalStorageDirectory().getAbsolutePath();
try{
String pathPrefix = extPath + "/Android/data/" + getApplication().getPackageName() + "/cache/";
//File extPathFile = getExternalFilesDir(pathPrefix+FileName);
Log.d("TAG", "pathPrefix="+pathPrefix);
Log.d("TAG", "FileName="+FileName);
File file = new File(pathPrefix, FileName+".txt");
if(file.exists()){
Log.d("TAG", "File("+pathPrefix+FileName+")exist");
};
OutputStreamWriter outStream =
new OutputStreamWriter(new FileOutputStream(file));
Logcat:
01-22 14:26:15.834: D/TAG(14290): pathPrefix=/mnt/sdcard/Android/data/mast.avalons/cache/
01-22 14:26:15.834: D/TAG(14290): FileName=S000004_21-10-2011
01-22 14:26:16.044: D/TAG(14290): java.io.FileNotFoundException: /mnt/sdcard/Android/data/mast.avalons/cache/S000004_21-10-2011.txt (No such file or directory)
Thanks!
Upvotes: 1
Views: 194
Reputation: 21564
I think you should create intermediate directories :
new File(pathPrefix).mkdirs();
Upvotes: 2