I know this drove me mad more than once, and the fact I have to copy paste some implementation from one app to another was even more frustrating...
So....... I've thought a while back to make a generic storage utility object, specifically for Android, (I already have something like that for Pure Java) and after a long while I have. I know this is a bit overkill, but hell, I would gladly pay with few extra lines of code to save hundreds, for a readable, comfortable and quick coding.
If you find the code useful, leave me a comment... I would like to know I'm not doing this for no good reason!
For me the code is pretty obvious, but then again I've been at it for years... let me know what is not clear so I can elaborate more about these subjects.
-- UPDATE --
I've released Cyborg not too long ago, and this sort of generic shared preferences is build in and optimized further in terms of how much code you need to write, You can find it here.
nice work!!. but I looks complex for a beginner. checkout this wrapper I made that addresses the issue... https://github.com/kcochibili/TinyDB--Android-Shared-Preferences-Turbo
ReplyDeleteThanks KC, This code was not meant for real beginners, though the example should be simple enough to use even for a beginner.
DeleteAs for your implementation... that was my initial approach which is good and is enough but I love generics, and that is why with the years it turned into this one...
Deadlink found.
ReplyDeleteSorry, I've missed that when rearranging my repositories.
DeleteOops, you've found a dead link.
ReplyDeleteplease live the link...
Sorry, I've missed that when rearranging my repositories.
Delete