B4i Library [Class] PreferenceManager

Filippo

Expert
Licensed User
Hi,

today I want to share my classe PreferenceManager with you.

v1.01
Fixed problem with password save/read.


IMG_0004.PNG
 

Attachments

Last edited:

Derek Johnson

Active Member
Licensed User
Thanks for creating that. That's really good.

Also it is a very good example of how to define and use classes.:)
 

Filippo

Expert
Licensed User
Thanks for creating that. That's really good.

Also it is a very good example of how to define and use classes.:)
I look forward when I can help someone with it. ;)
 

Alberto Iglesias

Well-Known Member
Licensed User
Hi,

today I want to share my classe PreferenceManager with you.

View attachment 30840
Hello Filippo,

I'm using this class a long time ago, but I found one bug when one client of mine told me this:

Supose you try to save this:

manager.SetString("Password","000000")
and when you try to retrieve, you get:

just "0"

and the expected is "000000"



thank you
 

Filippo

Expert
Licensed User
Hello Filippo,

I'm using this class a long time ago, but I found one bug when one client of mine told me this:

Supose you try to save this:

manager.SetString("Password","000000")
and when you try to retrieve, you get:

just "0"

and the expected is "000000"



thank you
Fixed problem with password save/read.
 

Alberto Iglesias

Well-Known Member
Licensed User
i found my mistake watching your sample:

I create a function to make easy the calls for your class and I initialize everytime, now I just check if initialized or not and works fine

B4X:
        'Dim manager As clsPreferenceManager
        If manager.IsInitialized = False Then 
           manager.Initialize
        End If
 

Filippo

Expert
Licensed User
i found my mistake watching your sample:

I create a function to make easy the calls for your class and I initialize everytime, now I just check if initialized or not and works fine

B4X:
        'Dim manager As clsPreferenceManager
        If manager.IsInitialized = False Then
           manager.Initialize
        End If
;)
Here an elegant, in my opinion, solution.
I never use the "= False" or "= true".

B4X:
If not(manager.IsInitialized) Then
    manager.Initialize
End If
 
Top