diff --git a/app/src/main/java/org/ntlab/amaryllis/client/Amaryllis.java b/app/src/main/java/org/ntlab/amaryllis/client/Amaryllis.java index fab3efb..b12f62f 100644 --- a/app/src/main/java/org/ntlab/amaryllis/client/Amaryllis.java +++ b/app/src/main/java/org/ntlab/amaryllis/client/Amaryllis.java @@ -1,13 +1,55 @@ package org.ntlab.amaryllis.client; import android.app.Application; +import android.content.SharedPreferences; public class Amaryllis extends Application { private String token = null; + private String uid = null; + private String password=null; + + public void setUid(String uid) { + SharedPreferences prefData = getSharedPreferences("pref_data", MODE_PRIVATE); + SharedPreferences.Editor editor = prefData.edit(); + editor.putString("uid", uid); + editor.commit(); + } + + public String getUid() { + if(uid == null){ + SharedPreferences prefData = getSharedPreferences("pref_data", MODE_PRIVATE); + uid = prefData.getString("uid", ""); + } + return uid; + } + + public void setPassword(String password) { + SharedPreferences prefData = getSharedPreferences("pref_data", MODE_PRIVATE); + SharedPreferences.Editor editor = prefData.edit(); + editor.putString("password", password); + editor.commit(); + } + + public String getPassword() { + if(password == null){ + SharedPreferences prefData = getSharedPreferences("pref_data", MODE_PRIVATE); + password = prefData.getString("password", ""); + } + return password; + } + + public void setToken(String token) { + SharedPreferences prefData = getSharedPreferences("pref_data", MODE_PRIVATE); + SharedPreferences.Editor editor = prefData.edit(); + editor.putString("token", token); + editor.commit(); + } public String getToken() { + if(token == null){ + SharedPreferences prefData = getSharedPreferences("pref_data", MODE_PRIVATE); + token = prefData.getString("token", ""); + } return token; } - public void setToken(String token) { - this.token = token; - } + }