I know it should be a nonsense but I´m having some difficults to store a image in a custom folder. I know how to store them into the cache directory or in the camera folder, but I want to store them into a custom folder and I´m having an error. I´m using this code:
File folder = new File(Environment.DIRECTORY_DCIM + "/ExtremEye");
folder.mkdirs();
fos = new FileOutputStream(new File(folder, "FRAME_"+ nombre + ".png"));
But I´m getting this logcat:
File not found: /DCIM/ExtremEye/FRAME_20131101_120104.png: open failed: ENOENT (No such file or directory)
It´s a simple question, I know, but I have been trying different ways and I didn´t succeed.
Thanks for help!!
from the logcat seems that is trying to access DCIM in the root /, but it should be on the External storage. Try this way:
File folder = new File(Environment.getExternalStorageDirectory(), Environment.DIRECTORY_DCIM + "/ExtremEye");
Related
I want load a file wav from sdcard in my android project but I don't succeed.
I'm using
File sdcard = Environment.getExternalStorageDirectory();
File file = new File(sdcard,"/mnt/sdcard/.....wav");
but I get this error
java.io.FileNotFoundException: /mnt/sdcard/mnt/sdcard/......wav (No such file or directory)
Can you help me, please?
the first parameter is already the path - do not put /mnt/sdcard/ to the second parameter
File sdcard = Environment.getExternalStorageDirectory();
File file = new File(sdcard,".....wav");
Remove this /mnt/sdcard/ from the line It is already there in file
Replace this:
File file = new File(sdcard,"/mnt/sdcard/.....wav");
with this:
File file = new File(sdcard,".....wav");
When I run the app on Nexus 5 there are no problem with the file but in another smartphone I have a problem, I think it could be the spaces and I deleted it.
The code is :
File file = new File(directory,new SimpleDateFormat("dd-MM-yyyy-HH:mm:ss",Locale.ROOT).format(new Date()).toString()+"-"+idUser+"-"+idTest+".txt");
FileOutputStream outputStream = new FileOutputStream(file);
path file: /storage/sdcard0/Nexio/Tests/23-07-2014-16:33:11-alex-0.txt
The directory exists. And the exception is "FileNotFoundException"
you are probably setting directory with a static string.. that would be my guess.. use http://developer.android.com/reference/android/os/Environment.html#getExternalStorageDirectory()
My application has a function of creating an xls file. After that I need to access that file manually. Now, the problem is, when i run the app on my device, I am able to locate the directories and my xls file in internal storage.
But when I try to run that in the AVD, I am not able to find the file. I also viewed file explorer but there also, I wasn't able to find my file.
Where does the file exists when created in AVD?
Below is the code :
File myDir = new File(Environment.getExternalStorageDirectory()+ "/PB/automation/mydir/");
myFolder.mkdirs();
File file = new File(myFolder, "demo.xls");
Trust me, there is nothing wrong with the code.
Below is the file explorer view :
I am writing to a path mnt/sdcard/foldername. I get no errors and the file is written, but when I browse the internal storage of my phone I can not find the folder. Where would the folder be located? I have a galaxy nexus?
Code is here:
File sdCard = Environment.getExternalStorageDirectory();
File directory = new File (sdCard.getAbsolutePath() + "/statReporter/");
directory.mkdirs();
Log.d("Tag", directory.toString());
//Path and name of XML file
File file = new File(directory, appendTimeStamp("phoneNum") + ".csv");
FileOutputStream fOut = new FileOutputStream(file);
OutputStreamWriter osw = new OutputStreamWriter(fOut);
//Write to CSV File
osw.write(message);
osw.write(',');
//Flush and close OutPutStreamWriter and close FileOutputStream
osw.flush();
osw.close();
fOut.close();
Log.d("File Logger:", "File write successfully!");
Cant find it in Windows Computer\Galaxy Nexus\Internal Storage but all other folders appear.
I used an app called OI File Managaer and I can view the folder and file on phone but how do I view it through Windows OS?
If you really want to find files on your device, I'd recommend one of the Google Play apps you can find (I personally like ASTRO File Manager) or, from the PC you can use (for instance) Android Commander (which, incidentally, will let you use the same file path structure you'll be using from within your developing environment).
I believe that Android devices will not actually show you all paths and available files when you browse it, for instance, with Windows Explorer.
If you're using Eclipse, in the DDMS perspective you can browse your device's file structure. On your right you have the "File Explorer" and as far as I remember, it's a pretty complete tool.
Don't use /mnt/sdcard for accessing external storage. You can use Environment.getExternalStorageDirectory() to access path to external storage. This may vary from device to device.
Is there a way to open assets or raw resource as File ? I have method that needs open file as File but since i want store my file in assets or in raw folder i cannot access them.
I tried open it with file:///android_asset/filename.xml but received FileNotFound exception.
File file = new File("....");
x.load(file);
Is there a way to open assets or raw resource as File ?
No, sorry. They do not exist as files. You can only get an InputStream.
If you're willing to zip up the file first, you can do this:
File dir = getFilesDir();
IoUtils.extractZipResource(getResources().openRawResource(R.raw.texfilezip), dir, true);
File textFile = new File(dir, "textfile.txt");