I would like to store user preferences in Firebase real time database instead of typical sharedPreferences.
As an example, my user should specify the itemId in order to access to this part of the database:
items
itemId
members
uid: true
So when the user fill in the itemId, I need to check if this itemId exists in the database and display error asking the user to fill in another itemId.
I envisage to use standard Preference screens and associate a custom PreferenceDataStore at least to handle the itemId.
When reading the documentation, I need to override getString/putString methods:
public class DataStore extends PreferenceDataStore {
@Override
public void putString(String key, @Nullable String value) {
// Save the value somewhere
}
@Override
@Nullable
public String getString(String key, @Nullable String defValue) {
// Retrieve the value
}
}
At the end, I need to manage it asynchronously in order to query my database and get some results.
So I'm wondering if using PreferenceDataStore is the good approach ... My initial idea was to avoid developping settings screens that already exist in Androidx Preference lib.
Thx for your help!
putString
in asynchronous mode, but how to implementgetString
? – Deaton