Firebase user preferences as android preferences/settings - android

I'm developing an Application using Firebase analytics, authentication and DB services.
I need to save some preferences and some settings, related to the user.
Most of them are managed in a "SettingsActivity" which is similar to the sample one provided by Android Studio, but with this configuration if the user changes the device, those preferences are lost.
The app should provide a customizable experience for each user. To achieve this I'd like my preferences to be saved on Firebase insted of in local Preferences.
How can I achieve this without have to change too much my app structure?
EDIT:
Here's an example:
The user download my App on first device (Dev-A), he sign up, then he goes to settings and set first setting from A to B, and second setting from A to D.
Then he decide to download my App on a second device (Dev-B), he log in, then he goes to settings.
On Dev-A, first setting is set to B and second setting is set to D.
On Dev-B, first setting is set to A and second setting is set to A.

You will need to store this information in Firebase Database.
Use the user'd UID you get from Firebase Auth in the Database to store the settings.
The data should be under '/users/{uid}'
This way, you will persist all user specific data across devices. (Since the same UID will be presented to same authentication account)
Check this link in Firebase documentation to set the database security

You should try this library:
A implementation of SharedPreferences which syncs with Firebase database to keep your SharedPreferences in sync between multiple devices of one user and/or to back them up for app re-installs!

Related

How to display any activity only once without using shared preferences?

I want to display term of service in my app only once when app launched without using shared preference because If user clear app data it will display again.
What you want to achieve can only be achieved with flags.
Shared preference -
Which you don't want to use it's okay.
Use any other database like firebase
You don't need to add email login etc firebase create ID for every new user so now store your flag inside this.
Simple.
So it wil not deleted too.
But user should logged in with e-mail if want to get retrieved the data.

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.

Android App Preference

I have this android app with user login and app settings.
app settings are save in default location com.package_preference.xml
when user logins. he or she can set the app settings like notification. or vibrate.
my problem is when another user logins every app settings set by the last user logged in will be use since it was stored localy.
any ways to handle this issue? or better ways to avoid this problems?
I was thingking saving that file on sqlite but that was a lot of work to do.
or name the preference file like user_id_preference.xml but i dont think this is feasible since app preference are save as com.package_preference.xml

Permanent access to app of dropbox account?

I have an app which links to an dropbox account. I am able to login once and is saves that. But each time it asks whether I want to allow access to the app or not . Is there a way to save this preference as well and provide access to the app permanently ?
Read again https://www.dropbox.com/developers/start/authentication#android especially "Return to your app after user authorization".
After successful .getSession().finishAuthentication() there is AccessTokenPair tokens = mDBApi.getSession().getAccessTokenPair() which will give You data, which You should save somewhere for later use (You can use SharedPreferences for this).
In start time of application You have to check existance of this saved data, and if it's there, You don't have to call .startAuthentication() again, instead You should call .setAccessTokenPair(access) with saved data as access (look at top of https://www.dropbox.com/developers/start/files#android ).

Is it possible to show screen only once when app starts up?

I want to be able to prompt the users to enter the details required for the app only when it starts up for the first time (not other times). These details will be held in a database on the phone.
Would it be better to check the database each time or put these details in a shared preference? Furthermore, is this type of activity even possible on Android?
Depends on the details really. If it is a large amount of information you might consider using a Database. For just basic identification information, SharedPreferences should be fine.
If you do use a Database, you might consider loading them into your Application object. This would depend on how frequently you use this information in your app.
To check for the first start of the app, a SharedPreference is generally used AFAIK.
Use SharedPreferences or Database depending on the data complexity and its need later on..
Store a Flag in SharedPreferences and set this when user enters the data.
Check that shared preferences flag while on your first activity and redirects accordingly(to Details/one time page) if required.
here even if a user manually deletes data using Settings > Manage app > your app > clear data, Your app will know to get the details then from user....

Categories

Resources