Admin
can you do something like getPrefs<Map<String, Object>>()?
Votes
0
Replies
24
Participants
Unknown
Messages
25
Admin
can you do something like getPrefs<Map<String, Object>>()?
Rank 2: Process
no
Admin
what's the error?
Rank 2: Process
this method returns io.appwrite.Preferences
Admin
So? My suggestion would make it return Preferences<Map<String, Object>>
Rank 2: Process
I had one idea and check this
Rank 2: Process
This gives me a new error
Rank 2: Process
I rewrite code as
Rank 2: Process
Map<String, Object> updatedAccountPrefsMap = (Map<String, Object>) updatedAccountPrefs.getData(); account.updatePrefs( Objects.requireNonNull(updatedAccountPrefsMap.replace("main_info", newProfileBio)),...```Rank 2: Process
and catch io.appwrite.exceptions.AppwriteException: Invalid prefs: Value must be a valid object.
Rank 2: Process
newProfileBio is a String
Rank 2: Process
Can I use JSONObject?
Admin
There's no need to use Objects.requireNonNull()
Admin
what happened when you tried getPrefs<Map<String, Object>>()?
Admin
last resort would be to create a new HashMap<String, Object>, add the entries from the existing prefs into it, and then pass it to updatePrefs()
Rank 2: Process
this is false in syntacs
Admin
What do you mean?
Admin
does getPrefs accept any arguments?
Okay, I've found the time to test it out.
It should be something like this.
// First get the map.Map<String, Object> map = (Map<String, Object>) pref.getData();
// You can add new prefmap.put("pref", "value");
// You can delete a prefmap.remove("pref");
// You can update pref.map.replace("pref", "newValue");
// Then, update itaccount.updatePrefs(map, /*... */);It's important you'll do all adding/removing/updating process on a second variable, as none of all those methods will return the object it self.
Rank 2: Process
Yes, this is correct answer! Thank you very much, it's working!
Rank 2: Process
But I have one question about other theme (coding isn't need)
Rank 2: Process
Where can I ask this? (not now)
Admin
Create a new post in #channel
Rank 2: Process
Ok
Rank 2: Process
[SOLVED]How to update Account Preferences with string.