Skip to content

Commit

Permalink
new basic features
Browse files Browse the repository at this point in the history
  • Loading branch information
chingiz committed Jul 20, 2017
1 parent a927391 commit ef24c31
Show file tree
Hide file tree
Showing 2 changed files with 54 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
SessionManagerDebug sessionManagerDebug = new SessionManagerDebug(getApplicationContext());
sessionManagerDebug.setString("test", "I'm SessionManager");
sessionManagerDebug.putString("test", "I'm SessionManager");

Log.d("MainActivity ", "onCreate: "+sessionManagerDebug.getString("test", "1"));
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

import android.content.Context;
import android.content.SharedPreferences;
import android.util.Log;
import java.util.Set;

/**
* Created by chingizh on 7/20/17.
Expand All @@ -12,7 +12,7 @@ public class SessionManagerDebug {

private SharedPreferences pref;

SharedPreferences.Editor editor;
private SharedPreferences.Editor editor;

private static final String INIT = "init";

Expand All @@ -21,7 +21,7 @@ public SessionManagerDebug(Context context){
pref = context.getSharedPreferences(INIT, PRIVATE_MODE);
}

public void setString(final String key, final String newValue) {
public void putString(final String key, final String newValue) {
editor = pref.edit();
editor.putString(key, newValue);
editor.apply();
Expand All @@ -31,4 +31,54 @@ public String getString(final String key, final String defValue) {
return pref.getString(key, defValue);
}

public void putInt(final String key, final int newValue) {
editor = pref.edit();
editor.putInt(key, newValue);
editor.apply();
}

public int getInt(final String key, final int defValue) {
return pref.getInt(key, defValue);
}

public void putFloat(final String key, final float newValue) {
editor = pref.edit();
editor.putFloat(key, newValue);
editor.apply();
}

public void putLong(final String key, final long newValue) {
editor = pref.edit();
editor.putLong(key, newValue);
editor.apply();
}

public long getLong(final String key, final long defValue) {
return pref.getLong(key, defValue);
}

public float getFloat(final String key, final float defValue) {
return pref.getFloat(key, defValue);
}

public void putBoolean(final String key, final Boolean newValue) {
editor = pref.edit();
editor.putBoolean(key, newValue);
editor.apply();
}

public boolean getBoolean(final String key, final Boolean defValue) {
return pref.getBoolean(key, defValue);
}

public void putStringSet(final String key, final Set<String> newValue) {
editor = pref.edit();
editor.putStringSet(key, newValue);
editor.apply();
}

public Set<String> getStringSet(final String key, final Set<String> defValue) {
return pref.getStringSet(key, defValue);
}

}

0 comments on commit ef24c31

Please sign in to comment.