Reputation:
My app creates files. Now, I save the name of these filename in SharedPreferences, and query the folder to get the files by the names stored in SharedPreferences. If someone goes to the folder and changes the name of a file, then that will be lost, as the new name will not be contained within my SharedPreferences, and hence I'll not be able to query it, to show it within my app. So, is there a way to make a file unmodifiable?
Upvotes: 0
Views: 96
Reputation: 766
You could create the files you do not want changed in your application's private data folder. Other applications and users do not have permission to modify those files.
To access your private folder:
File file = new File(getApplicationContext().getFilesDir(), "filename");
http://developer.android.com/reference/android/content/Context.html#getFilesDir()
These files will be deleted if your app is uninstalled.
Upvotes: 3