'Where did my file saved into External Storage in Emulator?
I can write to Emulator Internal Storage
context.openFileOutput(fileName, Context.MODE_PRIVATE).use {
it.write(outputMode.toByteArray())
}
Or write to Emulator Internal Storage
val file = File(context.filesDir, fileName)
parseFrom(FileInputStream(file))
This works fine.
I can find the file in ./data/data/mypackagename/files/ using Device File Explorer in Android Studio as shown below
However when I save them in External Storage
using
val path = context.getExternalFilesDir(null)
val letDirectory = File(path, folder)
letDirectory.mkdirs()
val file = File(letDirectory, fileName)
FileOutputStream(file).use {
it.write(outputMode.toByteArray())
}
I can still read it using
val path = context.getExternalFilesDir(null)
val letDirectory = File(path, folder)
letDirectory.mkdirs()
val file = File(letDirectory, fileName)
parseFrom(FileInputStream(file))
But I cannot find it in my Device File Explorer folder. I cannot find it in ./sdcard folder nor ./mnt/sdcard folder.
Where is it stored?
Note : This is on Android 11, where I use <uses-permission android:name="android.permission.MANAGE_EXTERNAL_STORAGE"/>
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|

