Skip to content

tiromansev/Android-Prefs-Wrapper

Repository files navigation

Android-Prefs-Wrapper

Android SharedPreferences wrapper

How to use

public class AppPrefs {

    public static BooleanPreference exampleBoolPref() {
        return BooleanPreference.
                builder().
                setKey("example_bool_pref").
                setDefaultValue(true).
                build();
    }

}
public class ExampleActivity extends AppCompatActivity {

    @Override
    public void onCreate(Bundle savedInstanceState) {
    	AppPrefs.exampleBoolPref().setValue(true);
    }

}

Download

Add it in your root build.gradle at the end of repositories:

	allprojects {
		repositories {
			...
			maven { url 'https://jitpack.io' }
		}
	}

Step 2. Add the dependency

	dependencies {
	        compile 'com.github.tiromansev:Android-Prefs-Wrapper:0.2.1'
	}

Maven:

<repositories>
		<repository>
		    <id>jitpack.io</id>
		    <url>https://jitpack.io</url>
		</repository>
	</repositories>

Step 2. Add the dependency

<dependency>
	    <groupId>com.github.tiromansev</groupId>
	    <artifactId>Android-Prefs-Wrapper</artifactId>
	    <version>0.2.1</version>
	</dependency>