Running on Nexus 4, when I call getExternalCacheDir().getAbsolutePath() , I get the path /storage/emulated/0/Android/Data/com.example.myapp/cache . The problem is that, as indicated in various places, /storage/emulated/0 generates the error "there is no such file or directory."
What I expect to get is something like /storage/emulated/legacy , since I am correctly querying the EXTERNAL_STORAGE environment variable with commands like System.getenv("EXTERNAL_STORAGE") .
I just use the if statement to check and correct the path in case it points to something different from what I get with getenv , but I want to understand why getExternalCacheDir() returns an invalid path, or if this function is somehow deprecated .
Additional notes: Xperia U runs CM11, works great; Targeting Nexus 4 with adb I get
ls /storage/emulated/0 /storage/emulated/0: No such file or directory
I have the appropriate permissions, because if I call, for example, echo "hi!" >> /storage/emulated/legacy/Android/Data/com.example.myapp/cache echo "hi!" >> /storage/emulated/legacy/Android/Data/com.example.myapp/cache , I have no hints, and when I call echo "hi!" >> /storage/emulated/0/Android/Data/com.example.myapp/cache echo "hi!" >> /storage/emulated/0/Android/Data/com.example.myapp/cache lead to errors. The latter is what I get from getExternalCacheDir .
I am interested in using this path with shell commands, not just Android API functions.
kalup source share