Android Question Save settings common across multiple applications

scubanarc

New Member
Licensed User
Longtime User
I'm having a hard time grasping how to save settings that are shared by multiple applications. Like let's say I have a company that has 5 applications and I want my users to login to just one of them, but maintain login across all 5. I know how to process login. I know how to save a map to a file and read it back, and I know how to request "WRITE_EXTERNAL_STORAGE" so that I can save that login in the Documents directory if I wanted to. The problem with that method is that it causes a new permission for the user.

How can I save some strings to an area that all of my applications have access to? I don't need file based storage, only some strings (login token, email address, that sort of thing).
 

JohnC

Expert
Licensed User
Longtime User
Android purposely "sandboxes" applications for protection.

Here are some ways to override this protection:

1) Allow all the applications to gain access to a common external memory location (as you mentioned this requires a permission).
2) Share the information using some cloud service, like a cloud server you host, or use the user's Google drive, etc - but this too will require the applications to have an "internet" permission.
3) Another possible method is to use Intents to do inter-app communication: https://www.b4x.com/android/forum/threads/tutorial-inter-app-communication-with-intents.30608/
 
Upvote 0

scubanarc

New Member
Licensed User
Longtime User
Cloud is definitely an option, but I'd still need to store away some sort of ID so that only the first app had to login. I'm not opposed to it, but I need to save something global somewhere.

Is there some sort of location like the Windows registry where you can stash a global read/write string?

Some apps, like Amazon related apps, share a login through the system global "accounts". I don't want to go that far.
 
Upvote 0

JohnC

Expert
Licensed User
Longtime User
Well, you could use method #3 and when one app "sends" an intent that "a setting has changed", the other apps can store the changed setting value in their own local settings storage area.

It should not be too difficult to keep each app's settings database in sync with the rest.
 
Upvote 0
Top