Java Code Examples for android.content.ContextWrapper#getSharedPreferences()
The following examples show how to use
android.content.ContextWrapper#getSharedPreferences() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: SharedPreferencesMyUtil.java From star-zone-android with Apache License 2.0 | 6 votes |
public static UserInfo queryUserInfo(ContextWrapper contextWrapper) { if (contextWrapper == null) { return null; } SharedPreferences sp = contextWrapper.getSharedPreferences(StorageConstant.SHARED_PREFERENCES_NAME_FILE_USER_INFO , 0); String headImg = sp.getString("headImg", ""); String cover = sp.getString("cover", ""); String nickname = sp.getString("nickname", ""); UserInfo userInfo = new UserInfo(); userInfo.setHeadImg(headImg); userInfo.setCover(cover); userInfo.setNickname(nickname); userInfo.setUsername(nickname); LoginResult loginResult = queryToken(contextWrapper); if (loginResult != null) { userInfo.setId(loginResult.getUserId()); } return userInfo; }
Example 2
Source File: SharedPreferencesMyUtil.java From star-zone-android with Apache License 2.0 | 5 votes |
public static void storeToken(ContextWrapper contextWrapper, LoginResult loginResult) { SharedPreferences sp = contextWrapper.getSharedPreferences(StorageConstant.SHARED_PREFERENCES_NAME_PASSPORT, 0); SharedPreferences.Editor editor = sp.edit(); editor.putLong("userId", loginResult.getUserId()); editor.putString("mobile", loginResult.getUsername()); editor.putString("token", loginResult.getToken()); editor.commit(); if (loginResult.getUserId() > 0) { MiPushClient.setAlias(MyApp.getInstance(), loginResult.getUserId() + "", null); Log.i(MY_TAG, "MiPushClient_setAlias:alias=" + loginResult.getUserId() + ""); } }
Example 3
Source File: SharedPreferencesMyUtil.java From star-zone-android with Apache License 2.0 | 5 votes |
public static LoginResult queryToken(ContextWrapper contextWrapper) { if (contextWrapper == null) { return null; } SharedPreferences sp = contextWrapper.getSharedPreferences(StorageConstant.SHARED_PREFERENCES_NAME_PASSPORT, 0); long userId = sp.getLong("userId", 0); String mobile = sp.getString("mobile", null); String token = sp.getString("token", null); LoginResult loginResult = new LoginResult(); loginResult.setUserId(userId); loginResult.setToken(token); loginResult.setUsername(mobile); return loginResult; }
Example 4
Source File: SharedPreferencesMyUtil.java From star-zone-android with Apache License 2.0 | 5 votes |
/** * @param contextWrapper * @param headFilePath 头像图片本地文件的绝对路径 */ public static void storeHead(ContextWrapper contextWrapper, String headFilePath) { if (contextWrapper == null) { return; } SharedPreferences sp = contextWrapper.getSharedPreferences(StorageConstant.SHARED_PREFERENCES_NAME_FILE_STORAGE , 0); SharedPreferences.Editor editor = sp.edit(); editor.putString("headFilePath", headFilePath); editor.commit(); }
Example 5
Source File: SharedPreferencesMyUtil.java From star-zone-android with Apache License 2.0 | 5 votes |
public static String queryHead(ContextWrapper contextWrapper) { if (contextWrapper == null) { return null; } SharedPreferences sp = contextWrapper.getSharedPreferences(StorageConstant.SHARED_PREFERENCES_NAME_FILE_STORAGE , 0); return sp.getString("headFilePath", null); }
Example 6
Source File: SharedPreferencesMyUtil.java From star-zone-android with Apache License 2.0 | 5 votes |
public static void storeHeadVersion(ContextWrapper contextWrapper, long headVersion) { if (contextWrapper == null) { return; } SharedPreferences sp = contextWrapper.getSharedPreferences(StorageConstant.SHARED_PREFERENCES_NAME_FILE_STORAGE , 0); SharedPreferences.Editor editor = sp.edit(); editor.putLong("headVersion", headVersion); editor.commit(); }
Example 7
Source File: SharedPreferencesMyUtil.java From star-zone-android with Apache License 2.0 | 5 votes |
public static Long queryHeadVersion(ContextWrapper contextWrapper) { if (contextWrapper == null) { return null; } SharedPreferences sp = contextWrapper.getSharedPreferences(StorageConstant.SHARED_PREFERENCES_NAME_FILE_STORAGE , 0); return sp.getLong("headVersion", 0); }
Example 8
Source File: SharedPreferencesMyUtil.java From star-zone-android with Apache License 2.0 | 5 votes |
public static void storeUserInfo(ContextWrapper contextWrapper, UserInfo userInfo) { if (contextWrapper == null) { return; } SharedPreferences sp = contextWrapper.getSharedPreferences(StorageConstant.SHARED_PREFERENCES_NAME_FILE_USER_INFO , 0); SharedPreferences.Editor editor = sp.edit(); editor.putString("headImg", userInfo.getHeadImg()); editor.putString("cover", userInfo.getCover()); editor.putString("nickname", userInfo.getNickname()); editor.commit(); }
Example 9
Source File: SharedPreferencesMyUtil.java From star-zone-android with Apache License 2.0 | 5 votes |
public static void storeMiRegid(ContextWrapper contextWrapper, String regid) { if (contextWrapper == null) { return; } SharedPreferences sp = contextWrapper.getSharedPreferences(StorageConstant.SHARED_PREFERENCES_NAME_MIPUSH , 0); SharedPreferences.Editor editor = sp.edit(); editor.putString("regid", regid); editor.commit(); }
Example 10
Source File: SharedPreferencesMyUtil.java From star-zone-android with Apache License 2.0 | 5 votes |
public static String queryMiRegid(ContextWrapper contextWrapper) { if (contextWrapper == null) { return null; } SharedPreferences sp = contextWrapper.getSharedPreferences(StorageConstant.SHARED_PREFERENCES_NAME_MIPUSH , 0); String regid = sp.getString("regid", ""); return regid; }
Example 11
Source File: CrashHandler.java From quickmark with MIT License | 5 votes |
/** * ��ʼ�� * * @param context */ public void init(Context context) { mContext = context; ContextWrapper a = (ContextWrapper) mContext.getApplicationContext(); SharedPreferences sp = a.getSharedPreferences("preferences", MODE_WORLD_READABLE); if (sp.getString("sendlog", "").equals("��") || sp.getString("sendlog", "").equals("")) { mDefaultHandler = Thread.getDefaultUncaughtExceptionHandler();// ��ȡϵͳĬ�ϵ�UncaughtException������ Thread.setDefaultUncaughtExceptionHandler(this);// ���ø�CrashHandlerΪ�����Ĭ�ϴ����� } }