In my app I'm using AndroidX DataStore to save preferences.
To do this, I followed the documentation and added a Context property at file-level like this:
val Context.dataStore: DataStore<Preferences> by preferencesDataStore(name = "preferences")
Now I want to dynamically access a DataStore with a different name, say "preferences_1" or "preferences_2", depending on a selected profile id.
I retrieve the profile id in my Activity onCreate
function and it stays the same for the whole lifetime of the activity.
How can I dynamically set the DataStore instance?