can you do something like getPrefs<Map<String, Object>>()?
no
what's the error?
this method returns io.appwrite.Preferences
So? My suggestion would make it return Preferences<Map<String, Object>>
I had one idea and check this
This gives me a new error
I rewrite code as
Map<String, Object> updatedAccountPrefsMap = (Map<String, Object>) updatedAccountPrefs.getData();
account.updatePrefs(
Objects.requireNonNull(updatedAccountPrefsMap.replace("main_info", newProfileBio)),
...```
and catch io.appwrite.exceptions.AppwriteException: Invalid prefs: Value must be a valid object.
newProfileBio is a String
Can I use JSONObject?
There's no need to use Objects.requireNonNull()
what happened when you tried getPrefs<Map<String, Object>>()?
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()
this is false in syntacs
What do you mean?
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 pref
map.put("pref", "value");
// You can delete a pref
map.remove("pref");
// You can update pref.
map.replace("pref", "newValue");
// Then, update it
account.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.
Yes, this is correct answer! Thank you very much, it's working!
But I have one question about other theme (coding isn't need)
Where can I ask this? (not now)
Create a new post in <#1072905050399191082>
Ok
[SOLVED]How to update Account Preferences with string.
Recommended threads
- Display an in-app in the user mobile?
Would it be possible to send a message that would display an in-app in the user mobile?
- Project stuck in read-only mode on free ...
Hi Appwrite team! I’m a student using the free plan, and my project (ID: 68e48f780001232ad879) is currently stuck in read-only mode. I can’t create or update ...
- Flutter OAuth2 Google Login – Redirect I...
i tried implementing OAuth2 Google Login in my app, and it works fine for the most part, the problem am facing is when i chose a google account to sign in/up wi...