kompiler Member Licensed User Longtime User Oct 21, 2019 #1 Hello, how can I delete a single key and value in PreferenceManager? I found this way Code: Dim PMR As Map=PreferenceManager1.GetAll PreferenceManager1.ClearAll For K=0 To PMR.Size-1 Dim S As String=PMR.GetKeyAt(K) If S<>"Key_to_delete" Then PreferenceManager1.SetString(PMR.GetKeyAt(K),PMR.GetValueAt(K)) End If Next but it takes a long time.
Hello, how can I delete a single key and value in PreferenceManager? I found this way Code: Dim PMR As Map=PreferenceManager1.GetAll PreferenceManager1.ClearAll For K=0 To PMR.Size-1 Dim S As String=PMR.GetKeyAt(K) If S<>"Key_to_delete" Then PreferenceManager1.SetString(PMR.GetKeyAt(K),PMR.GetValueAt(K)) End If Next but it takes a long time.
LucaMs Expert Licensed User Longtime User Oct 21, 2019 #2 I'm pretty sure Erel would suggest this to you: https://www.b4x.com/android/forum/t...alog-cross-platform-forms.103842/#post-651047 Upvote 0
I'm pretty sure Erel would suggest this to you: https://www.b4x.com/android/forum/t...alog-cross-platform-forms.103842/#post-651047
Erel B4X founder Staff member Licensed User Longtime User Oct 22, 2019 #3 kompiler said: but it takes a long time. Click to expand... Test it in release mode. What is the output of: Code: Dim n As Long = DateTime.Now 'your code here Log(DateTime.Now - n) Upvote 0
kompiler said: but it takes a long time. Click to expand... Test it in release mode. What is the output of: Code: Dim n As Long = DateTime.Now 'your code here Log(DateTime.Now - n)
kompiler Member Licensed User Longtime User Oct 22, 2019 #4 Tested several times in release mode Code: ** Activity (main) Resume ** *** Service (starter) Create *** ** Service (starter) Start ** ** Activity (main) Create, isFirst = true ** ** Activity (main) Resume ** 1833 1480 2007 1853 2030 I have 230 entries (key / value) in PreferenceManger Upvote 0
Tested several times in release mode Code: ** Activity (main) Resume ** *** Service (starter) Create *** ** Service (starter) Start ** ** Activity (main) Create, isFirst = true ** ** Activity (main) Resume ** 1833 1480 2007 1853 2030 I have 230 entries (key / value) in PreferenceManger
DonManfred Expert Licensed User Longtime User Oct 22, 2019 #5 what if you try just try to clear (set value to an empty string) the value for Key_to_delete only instead of clearing all and set them all new. Upvote 0
what if you try just try to clear (set value to an empty string) the value for Key_to_delete only instead of clearing all and set them all new.
Erel B4X founder Staff member Licensed User Longtime User Oct 22, 2019 #6 What are you using PreferencesManager for? There are probably better options available. Upvote 0
kompiler Member Licensed User Longtime User Oct 22, 2019 #7 I use to store variables and settings without access to mass storage Upvote 0
Erel B4X founder Staff member Licensed User Longtime User Oct 22, 2019 #8 There are much better options. The best one is KVS2. You can always store data in File.DirInternal. Upvote 0