change variable value inside app from outside - android

I want to declare a key inside my code and publish app with this key, then when app is published I want to be able change that key.
But my aim is to have one app and customize it for different users.
Do you have any offer?
May you explain a scenario?
Note : better to say that I want to separate each user's version by a unique key;
1- I can do this : I can change the variable value, publish app and send for user. But I wand to change key value in a published app, not from source code and re-publish.
2- using external file, shared-preference, and other ways, user will loose his version when uninstall app, and I want to avoid it.

You can just declare key in String.xml,
if you want to changes key run time, you have to go with sharedpreference in android, this store data in xml format.
more help visit this link, SharedPreferences : no saving to device, change it inside a packed app!
also this will help you Storage option in android : no storage, it is change value in a compiled app!

Related

What is most simple way to send notification of unexpected events to users of Android application?

For example I expect this kind of situation: data in my application lost relevance and so it usless until update. And until update it have to show users some predefined message.
Is here any simple and free solution to this task?
Guess I can use some server to somehow send simple messages... but it sounds way too complicated.
If this is important I use Xamarin.
Update: main difficulty here is fact - my application can't in any way define if it's outdated or not. This may happen in random moment.
Although the requirement is not very clear I assume Update here means app update.
each time user launches app make call to an api on ur server to check if user needs to update app
If that returns true take user to a static view that says app needs update and redirects user to google play to install updates
If you want to avoid using a server, you should try Firebase (https://firebase.google.com/). More specifically, you should use Firebase Remote Config (https://firebase.google.com/features/remote-config/).
Define in a key-value pair of something like minimum_app_version_required in Firebase Remote Config. Every time user opens the your app, compare the values of app version and minimum_app_version_required that you are getting from Firebase console and show a dialog box accordingly. You can also change the value of minimum_app_version_required anytime you want.
Just set some internal flag. That when that situation occurs, you can set the flag to true and just edit whatever layout element you are using such as listView or any other element with your predefined messages saved in strings.xml. You can also build any custom pop up screen, depends how you want to show them. Let me know if you didn't understand or exactly how you want?
Need to implement versioning for this problem. To achieve this, you have to maintain a version number in server, this is the version number you app will have to save and use it to validate with server. If both are not same, then app will get the latest data from the server.

What happens if I change my Preference settings of SharedPreference

what if I have a Code like this:
SharedPreferences prefs=getSharedPreferences("myPrefs",0);
And now I am so dumb and set it to (lets say the first release of my app had the above code....now several months later I release it with the code change below on the store)
SharedPreferences prefs=getSharedPreferences("myPrefs",1);
So I change the acces of it from 0(private) to 1(world readable) or 2 (world writeable)
Are there now two Preferences? So I have to sets of Preferences with different Key-Value pairs and different read/write visibilities in them but all have the same name/key?!
Thank you
since AFAIK android allocate a linux user to each app to acheive some kind of sandbox environment, my guess is that you only change the underline file linux premissions from private (access to the app's user only) to readable by all other programs, if they can access it they would be able to read it.

Share data between multiple apps

I have multiple apps that have some sort of in-app currency (i.e gold).
The gold (Integer value) should be accessable through all of my apps. All of my own apps should be able to read/write the value.
It is important that only my apps are able to write the value, it doesn't matter if anyone else can read it.
It's also important that I do not know which of my apps is installed. There is no 'main'-app at all. It should be irrelevant which of my apps is installed and in which order.
The value does not have to be shared between the apps during runtime, I rather thought of something like sharedPreferences or an SQL database.
Where/How should I store this value?
Which is the preferred solution to this problem (if there is any)?
If you need to share data between two (or more) apps, you can set to them the same android:sharedUserId (in AndroidManifest.xml) so the other app can read/write in the private data of the other app.
android:sharedUserId
The name of a Linux user ID that will be shared
with other applications. By default, Android assigns each application
its own unique user ID. However, if this attribute is set to the same
value for two or more applications, they will all share the same ID —
provided that they are also signed by the same certificate.
Application with the same user ID can access each other's data and, if
desired, run in the same process.
Doc here.

Making a set up screen on first start up

I'm here today asking someone if they know a way to make a set up screen on first start up.
Here's the scenario: When someone downloads my app and uses it for the first time, it has to show a method where users make a password. On subsequent uses, I don't want it to be shown anymore. Does anybody know how to do this?
You can use the SharedPreferences for this purpose.
At the start of your application, check if the key "myKey+versioncode" is present or not in the SharedPreferences. If it not stored, then it means your application has not bee started yet, let the user create his/her password. Once the password is created, add the SharedPreferences "myKey+versioncode" with any value you like, and next time you will find this SharedPreferences, so it means the user already started the application and created its password.
However be careful about the "versionning" of this key, you might also want to keep a single key instead of one per version of your application.
Edit: Concept found at the time I was looking for EULA inplementation, here: Simple EULA implementation for Android

How do I change my Application name

I would like to make a slight change to my application's name. I read that it can work if both applications are signed with the same signature and is given the same userId then they can share information and I can migrate the original application's information to the new one. It is very important that the user gets the notification to upgrade. Will the user receive the update to upgrade if its done this way?
Your users will still get the upgrade, as long as you don't change the top level java package name.
Do you mean the actual name (human readable) or the application package? You can change the name, description, etc. at any time (though it might be confusing for existing users). On the other hand, you cannot change the package name, you need to publish a new app. Unless the current app already has the sharedUserId, set you cannot really use that option: setting it will change the UID and the application won't be able to see its own files. Two solutions to this:
export the data in some shared format (XML, CSV, JSON, etc.)
write a content provider and use a signature permission to make sure only your apps can read from it.

Categories

Resources