Can someone change my app's preferences? - android

I want to create a preference file for my app and I want to ensure that no one will be able to change the content of the file. Can It be changed not by my app?(I change my preferences file by the code, I don't allow the user to change it with the app)

When you save in shared preferences file, it cannot be changed by some other user. However, if he has a rooted phone, it is possible for him to view shared preferences file, through command-line adb root commands, but it will be read-only so he cannot change it. If he then tries to make it read-write using
chmod 666
or similar options, it might affect your shared preferences, and the working of your app depending on how your app uses those shared preferences, but this will be momentarily for that execution and again a fresh read-only preferences file will be generated by the app. So yes, in rooted phone cases, it might be possible. But for general non-rooted cases, it cannot be done.

Related

How to refresh SharedPreferences after adding an xml file to its storage location

I have the following problem: Since I want to keep my shared preference data even if the .apk is uninstalled I copy its .xml file to an external location as described here: Android Backup of ENTIRE SharedPreferences file. However, after reinstalling the app and starting the application I import the .xml to the shared preferences location but it won't be found by the app at the very first time. It works after shutting the app down and restarting it again. What can I do that it already works from the beginning? It seems like to be necessary to refresh the shared preferences directory, but how can that be done within the app?
Thanks in advance
You can put files in a directory derived from Environment.getExternalStorageDirectory(). These files will persist after an uninstall. However, a user can delete those files any time they like, regardless of whether your app is installed or not.

In Android Is there a configuration file somewhere where I can manipulate those properties that are visible in the "Settings" app?

In Android Is there a configuration file somewhere where I can manipulate those properties that are visible in the system "Settings" app?
Or how can I (maybe programmatically or via a script or whichever way) manipulate the values found in system "Settings" app?
I answered this myself in another thread here:
Is it safe to edit settings.db in Android
Basically, there is not a configuration file as such, but the settings are stored in an sqlite database in this directory:
/data/data/com.android.providers.settings/databases/settings.db
You can use an sqlite browser to view and modify the values in there. The database is then exposed to the Android operating system through a settings-ContentProvider. As I have noted however, sometimes there is a mismatch between settings found in the settings app and in the database. This is probably because (of a bug) the settings app caches these settings locally. It is the settings exposed through the ContentProvider that are used by the system though as I have tested here.

hide or block access to the Shared Preferences file in Android

Is possible to hide or block access to the shared preferences file?
I'm using this file to store some information about mi apk and I would like to know if is possible not allowed to read or modify the file (including root devices).
Thank You very much in advance
You can store the data in encrypted form in SharedPrefernce. It will be simple approach. also by using proguard tool you can disable the reverse engineering of apk file.
Sadly there would be no way to do that on a device, if a device has root it will have sufficient privileges to read your Shared Preferences as well as your SQLite databases and even Account Manager if it wants to.
You can look into linux file permissions if you want to learn more but any device that has root will be able to access your shared preferences.
If there is sensitive data on in your Shared Preferences just warn the user that if there device is rooted they are at risk. Traditionally for example on Nexus devices if you want to root the device it will wipe the entire thing but on specific devices there are exploits that won't require a wipe so you might be at risk.
Hope that helps.

does variables in shared preferences share accross applications?

I want to share variable between two android application so I stored it in shared preference but when I reinstalled the application that store the variable the second application didn't see the variable, what is the best way to share variable between two application and dealing with situation when one of them will be reinstalled
I used this code
SharedPreferences globals_prefs = ctx.getSharedPreferences("globals_prefs", Context.MODE_WORLD_WRITEABLE);
The SharedPreferences in one application is stored as a prefs.xml file in a separate folder dedicated for you app in the Android File System. So when you uninstall an app, this folder also is deleted, thereby, all Preferences made by your app is removed. So a better way is to use Files to store it in the sdCard.
Note: currently this class does not support use across multiple processes. This will be added later.
From android dev documents
http://developer.android.com/reference/android/content/SharedPreferences.html
File or sqlite database on public directory would do the trick when sharing data
When you uninstall an app shared preference and internal cache is wiped out, so the only way is to use external storage.

Android save confidential file

Currently I am working on an app which has files stored in the res/raw folder.As I understood, these files are only readable but not writable?
My problem is that I need to change this files, when someone puts in a serial number, so that certain functionalists will be activated.
Also I do not really like to put the files as public on the SD card, since the users should not be able to get the content of these files.
How can I achieve this problem?
First thought would be:
The serial number and other settings information I am storing in the shared preferences...
Also my question is, are the shared preferences accessible for the user, so that he can see, change those settings by himself?
If not then I could store the information to activate the functionalists in there.
Does anyone has some other suggestions?

Categories

Resources