Bulldog uses annotation processing and Kotlin delegated properties to simplify reading and storing values in Android preferences.
With Bulldog we can read and write values just like a normal object
UserSettings().id = 4
// Output 4
But how does it works ?
1- First import dependencies in build.gradle
2- Init BulldogContext in App class.
3- Define your model using an object annotated with @Bulldog, here you can also set default values for each property.
4- Bulldog will generate a classe at compile time with the name UserSettings. Use this class to read and store values, under the hood is uses Android preferences to store and retrieve values.
Generated class contains a clearXXX() method for each property and a human readable toString() implementation.
Just access object property like a normal object.
Bulldog generates a clear method for each entry.
Bulldog also generates a
toString() human readable implementation.
Bulldog supports Enum type using the @Enum annotation.
For more info take a look at:
How to use it - Bulldog
UserSettings. Use it like a normal object to access values, under the hood it uses Kotlin delegated properties to read…
Android library to simplify reading and writing to SharedPreferences, never write code like this anymore…
Thanks that’s all !!!
Sérgio Serra @Android Developer