SessionManager

Additional

Language
Java
Version
1.2 (Jan 8, 2018)
Created
Jul 20, 2017
Updated
Aug 3, 2018
Owner
Chingiz Huseynzade (Chingiz)
Contributors
MFlisar
Chingiz Huseynzade (Chingiz)
2
Activity
Badge
Generate
Download
Source code
APK file

Commercial

SessionManager-Android

Small Shared Preference Library for Android

Download

You can download a source code from Github's releases page.

Or use Gradle

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.Chingiz:SessionManager-Android:1.1'
}

How do I use SessionManager?

Before using SessionManager initialize the SessionManager on your Application class.

public class SessionManagerApplication extends Application {
    @Override
    public void onCreate() {
        super.onCreate();
        new SessionManager.Builder()
                        .setContext(getApplicationContext())
                        .setPrefsName(SessionKeys.PREFS_NAME.getKey())
                        .build();
    }
}

Step 2 (create enum class) :

public enum SessionKeys {

    PREFS_NAME("test"),
    TEST("test");

    private String key;

    SessionKeys(String key) {
        this.key = key;
    }

    public String getKey() {
        return key;
    }
}

Step 3:

@Override
protected void onCreate(Bundle savedInstanceState) {
 ...
 SessionManager.putString(SessionKeys.TEST.getKey(), "I'm SessionManager");
 Log.d("Main ", "onCreate: "+SessionManager.getString(SessionKeys.TEST.getKey(), "1"));
}

License

MIT licensed, (c) @hchingiz