android - /storage/emulated/0 obtained from getExternalCacheDir() generates "no such file or directory" error -
android - /storage/emulated/0 obtained from getExternalCacheDir() generates "no such file or directory" error -
running on nexus 4, when phone call getexternalcachedir().getabsolutepath()
path /storage/emulated/0/android/data/com.example.myapp/cache
. problem that, stated in different places, /storage/emulated/0
generate "no such file or directory" error.
what expect /storage/emulated/legacy
, correctly querying external_storage
environment variable commands system.getenv("external_storage")
.
i utilize if statement check , right path in case point different getenv
, want understand why getexternalcachedir()
returns invalid path, or if function has been deprecated somehow.
additional notes: on xperia u running cm11 works fine; targetting nexus 4 adb
get
ls /storage/emulated/0 /storage/emulated/0: no such file or directory
i've proper access permissions, since if call, example, echo "hi!" >> /storage/emulated/legacy/android/data/com.example.myapp/cache
have no clues, while calling echo "hi!" >> /storage/emulated/0/android/data/com.example.myapp/cache
results in errors. latter getexternalcachedir
.
i'm interested in using path shell commands, not android api functions.
getexternalcachedir gives valid path. can read/write given external storage mounted , have proper access permissions.
that :
if (media_mounted.equals(environment.getexternalstoragestate()) // mounted && context.checkcallingorselfpermission("android.permission.write_external_storage") == packagemanager.permission_granted) { // have permissions file mytempdir = new file(getexternalcachedir(), "tempdir"); mytempdir.mkdirs(); // create , write files }
hope helps.
android storage android-sdcard
Comments
Post a Comment