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
- Flutter Android oAuth is no more working
I currently don't get the oAuth login to work in flutter android. it works on ios and on web. but when try to use it on Android, i get to the point where the ca...
- I'm experiencing a critical bug on Appwr...
Hey <@870607367597850624> team / support š I'm experiencing a critical bug on Appwrite Cloud that's blocking my production Flutter app. I've already filed GitH...
- Database listRows method call failing in...
I'm getting an error when trying to use listRows in a flutter app on a database. It seems something in the backend has changed because the production version of...