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
- Subscription Problem
I'm making an app in RN with Expo and Appwrite and there's a functionality which allows the user to create a task/test (i'll be reffering to them collectively a...
- Auth not working on expo react native
I'm trying to launch a development server with expo go and appwrite as a backend. On my windows pc, I've got a local docker instance of appwrite running as my b...
- Bug Report: Crash when trying to createR...
https://github.com/appwrite/sdk-for-android/issues/96 I think the bug is related with this one https://discord.com/channels/564160730845151244/1443887021314539...