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
- custom domain with CloudFlare
Hi all, it seems that CloudFlare has blocked cross-domain CNAME link which made my app hostname which is in CloudFlare, unable to create a CNAME pointing to clo...
- My organization's project is blocked
My organization's project is blocked so unblocked my organization then I will this
- Can't Create An Account with Gmail Domai...
Hi, when using account.create() to register a new user with the Gmail domain, I got "There was an error processing your request. Please check the inputs and try...