I am trying to save a file in my Android app so that I can access it using a file explorer. Since I couldn´t do this, I created a simpler app in which I only create a file and save it to see where is it stored. But I can´t see it no matter the way I do this.
Here is my code:
Calendar calendar = Calendar.getInstance();
String myFormat = "dd-MM-yyyy";
SimpleDateFormat sdf = new SimpleDateFormat(myFormat, Locale.FRANCE);
String today = sdf.format(calendar.getTime());
//Obtiene ruta de sdcard
File pathToExternalStorage = Environment.getExternalStorageDirectory();
//agrega directorio /myFiles
File appDirectory = new File(pathToExternalStorage.getAbsolutePath() + "/biciMAPS/");
if ( !appDirectory.exists() ) {
if ( !appDirectory.mkdirs()) {
Toast.makeText(MainActivity.this, "could not create directory: " + appDirectory.getAbsolutePath(), Toast.LENGTH_LONG).show();
return;
}
}
//Crea archivo
File saveFilePath = new File(appDirectory, today + ".csv");
Log.i("AAARCHIVOOO", saveFilePath.getAbsolutePath());
And this is what the Log.i shows:
I/AAARCHIVOOO: /storage/emulated/0/biciMAPS/24-09-2020.csv
I have used the ES File Explorer and I have noticed that /storage/emulated/0 is referred to the internal storage, but I can´t find the biciMAPS folder.
Any idea?
Thank you!
/storage/emulated/0
is actually /data/media
in the file-system.
Likely you have to create the file with saveFilePath.createNewFile()
.
And maybe also put some content into it.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.