Android easy shared preferences with preference model (POJO)
maven { url "https://dl.bintray.com/sahurjt/APref/" }
implementation 'com.sahurjt:apref:1.0.0'
Example Source Code
APref.init(getApplicationContext());
// with sp filename
APref.init(getApplicationContext(),"myPref");
APref<PreferenceModel> mSettings = APref.getInstance(PreferenceModel.class);
// accessing a value
int age = mSettings.object.age;
// update a value
mSettings.object.age = 5;
// or update whole object
PreferenceModel data = new PreferenceModel();
data.age = 6;
data.name = 'test';
mSettings.object = data;
// commit all changes
mSettings.commit();
// reset current object (mSettings.object) to empty object
mSettings.reset(true);
// update the object (mSettings.object) with data present in shared preference file
mSettings.reset(false);