My app will be writing some files to the storage which will be used by the app when in use (like a config). This config is time dependent and will be replaced by app when required.
Currently, I am writing this to the sdcard using Environment.getExternalStorageDirectory(). But this is visible when user used a file browser and could be deleted.
Is it possible for me to prevent the file deletion except by the application itself?
I tried using Environment.getDataDirectory() but i do not have permission to write there. Is there an other way?
Yes. Instead of saving in public location like SD card, write your file in application private space (internal storage), like:
See docs for more details. Be avare, that it is NOT equivalent of SD card due to limited space you got there.