I have a simple app that access and writes data to external storage. Everything works fine until I go to Settings -> Apps -> App Info and clear data via \"Clear data\" button, t
I have encountered and solved this exact problem.
Clicking the Clear Data button causes Android to stop your app from running and delete the entire application-specific folder "mnt/sdcard/Android/data/your.package.name"
.
However, I had a separate process that was started from Runtime.getRuntime().exec()
that was still running and it was writing to this folder. This caused the folder to be stuck in a locked state and caused the same symptom you described when my app called getExternalCacheDir()
. Running adb shell
and then ls
from within the /mnt/sdcard/Android/data folder showed that the folder was locked by a process. Running ps
showed that my other process was still running.
The solution was to properly kill the other process that was still writing to my application's application-specific folder before calling getExternalCacheDir()
.