app Token

public class Config {
    private static final String TOKEN_KEY = "token";
    private static final String APP_ID = "com.jiangcun.secret";
    public static String getCacheToken(Context context){
        return context.getSharedPreferences(APP_ID , Context.MODE_PRIVATE).getString(TOKEN_KEY,null);   //根据 Token_KEY 获取token.
    }

    public static void cacheToken(Context context,String token){                     //传入token,保存
        SharedPreferences.Editor editor = context.getSharedPreferences(APP_ID,Context.MODE_APPEND).edit();
        editor.putString(TOKEN_KEY,token);
        editor.commit();
    }
}

 

posted @ 2017-08-15 00:46  halo-漾  阅读(289)  评论(0编辑  收藏  举报