List of usage examples for android.content SharedPreferences getString
@Nullable String getString(String key, @Nullable String defValue);
From source file:com.apptentive.android.sdk.module.engagement.interaction.InteractionManager.java
private static Targets loadTargets(Context context) { SharedPreferences prefs = context.getSharedPreferences(Constants.PREF_NAME, Context.MODE_PRIVATE); String targetsString = prefs.getString(Constants.PREF_KEY_TARGETS, null); if (targetsString != null) { try {//from w ww . j a v a 2s .c o m return new Targets(targetsString); } catch (JSONException e) { Log.w("Exception creating Targets object.", e); } } return null; }
From source file:com.doplgangr.secrecy.FileSystem.storage.java
private static String ROOT() { SharedPreferences settings = CustomApp.context.getSharedPreferences(Config.settingsStore, 0); return settings.getString(Config.root, Environment.getExternalStorageDirectory().getAbsoluteFile() + "/SECRECYFILES"); }
From source file:com.geotrackin.gpslogger.senders.osm.OSMHelper.java
public static OAuthConsumer GetOSMAuthConsumer(Context ctx) { OAuthConsumer consumer = null;//w w w. ja v a 2 s .c o m try { int osmConsumerKey = ctx.getResources().getIdentifier("osm_consumerkey", "string", ctx.getPackageName()); int osmConsumerSecret = ctx.getResources().getIdentifier("osm_consumersecret", "string", ctx.getPackageName()); consumer = new CommonsHttpOAuthConsumer(ctx.getString(osmConsumerKey), ctx.getString(osmConsumerSecret)); SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(ctx); String osmAccessToken = prefs.getString("osm_accesstoken", ""); String osmAccessTokenSecret = prefs.getString("osm_accesstokensecret", ""); if (osmAccessToken != null && osmAccessToken.length() > 0 && osmAccessTokenSecret != null && osmAccessTokenSecret.length() > 0) { consumer.setTokenWithSecret(osmAccessToken, osmAccessTokenSecret); } } catch (Exception e) { //Swallow the exception } return consumer; }
From source file:com.apptentive.android.sdk.module.engagement.interaction.InteractionManager.java
private static Interactions loadInteractions(Context context) { SharedPreferences prefs = context.getSharedPreferences(Constants.PREF_NAME, Context.MODE_PRIVATE); String interactionsString = prefs.getString(Constants.PREF_KEY_INTERACTIONS, null); if (interactionsString != null) { try {//from w w w. j a va2 s .co m return new Interactions(interactionsString); } catch (JSONException e) { Log.w("Exception creating Interactions object.", e); } } return null; }
From source file:com.fusionx.lightirc.util.SharedPreferencesUtils.java
public static ServerConfiguration.Builder getDefaultNewServer(final Context context) { final ServerConfiguration.Builder builder = new ServerConfiguration.Builder(); final SharedPreferences preferences = PreferenceManager.getDefaultSharedPreferences(context); final String firstNick = preferences.getString(PreferenceConstants.PREF_DEFAULT_FIRST_NICK, "holoirc"); final String secondNick = preferences.getString(PreferenceConstants.PREF_DEFAULT_SECOND_NICK, ""); final String thirdNick = preferences.getString(PreferenceConstants.PREF_DEFAULT_THIRD_NICK, ""); builder.setNickStorage(new NickStorage(firstNick, secondNick, thirdNick)); final String realName = preferences.getString(PreferenceConstants.PREF_DEFAULT_REALNAME, "HoloIRCUser"); builder.setRealName(realName);//from ww w .j a v a2s.c om final boolean autoNick = preferences.getBoolean(PreferenceConstants.PREF_DEFAULT_AUTO_NICK, true); builder.setNickChangeable(autoNick); builder.setServerUserName("holoirc"); return builder; }
From source file:realizer.com.schoolgenieparent.ServerUtilities.java
/** * Unregister this account/device pair within the server. *///w w w . j av a 2 s. co m static void unregister(final Context context, final String regId) { Log.i(Config.TAG, "unregistering device (regId = " + regId + ")"); //String serverUrl = Config.URL + "/deregisterStudentDevice/" + studentID + "/" + regId; // Map<String, String> params = new HashMap<String, String>(); //params.put("regId", regId); SharedPreferences sharedpreferences = PreferenceManager.getDefaultSharedPreferences(ctx); String did = sharedpreferences.getString("DWEVICEID", ""); String userid = sharedpreferences.getString("UidName", ""); String accesstoken = sharedpreferences.getString("AccessToken", ""); try { postUnregister(userid, did, accesstoken); //GCMRegistrar.setRegisteredOnServer(context, false); String message = context.getString(R.string.server_unregistered); Config.displayMessage(context, message); } catch (Exception e) { // At this point the device is unregistered from GCM, but still // registered in the server. // We could try to unregister again, but it is not necessary: // if the server tries to send a message to the device, it will get // a "NotRegistered" error message and should unregister the device. String message = context.getString(R.string.server_unregister_error, e.getMessage()); Config.displayMessage(context, message); } }
From source file:de.itomig.itoplib.ItopConfig.java
public static int getItopNotifySetting() { SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(itopAppContext); int mNotifyCondition = Integer.valueOf(prefs.getString(KEY_NOTIFY, "0")); return mNotifyCondition; }
From source file:Main.java
/** * Returns the cached key for this device. Device keys are stored in SharedPreferences and are * used to track devices. Returns null if no device key was cached. * * @param username REQUIRED: The current user. * @param userPoolId REQUIRED: Client ID of the application. * @param context REQUIRED: Application context. * @return device key as String, null if the device-key is not available. *///from w w w . j a v a2 s . c o m public static String getDeviceKey(String username, String userPoolId, Context context) { try { SharedPreferences cipCachedDeviceDetails = context .getSharedPreferences(getDeviceDetailsCacheForUser(username, userPoolId), 0); if (cipCachedDeviceDetails != null && cipCachedDeviceDetails.contains(COGNITO_DEVICE_KEY)) { return cipCachedDeviceDetails.getString(COGNITO_DEVICE_KEY, null); } } catch (Exception e) { Log.e(TAG, "Error accessing SharedPreferences" + e.getMessage()); } return null; }
From source file:fr.outadev.splatcompanion.StageRotationUpdater.java
/** * Fetches the freshest schedules available (from cache or from the API). * * @param context A context/* ww w . j a v a 2s . co m*/ * @return A list of schedules containing the data * @throws IOException * @throws JSONException */ public static List<Schedule> getFreshestData(Context context) throws IOException, JSONException { SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(context); String cache = prefs.getString(KEY_LAST_CACHED_DATA, null); if (cache != null) { try { List<Schedule> cachedSchedules = parseSchedules(cache); // If the cached schedules aren't empty if (cachedSchedules != null && !cachedSchedules.isEmpty()) { // If the cached schedules are still fresh if (cachedSchedules.get(0).getEndTime() > System.currentTimeMillis()) { Log.d(StageRotationUpdater.class.getName(), "Using cached data"); return cachedSchedules; } } } catch (JSONException e) { e.printStackTrace(); } } Log.d(StageRotationUpdater.class.getName(), "Fetching fresh data"); String freshData = getScheduleDataFromAPI(); prefs.edit().putString(KEY_LAST_CACHED_DATA, freshData).apply(); return parseSchedules(freshData); }
From source file:Main.java
/** * Returns the cached device secret for this device. Device secret is generated when the device * is confirmed and is used for device identification. * * @param username REQUIRED: The current user. * @param userPoolId REQUIRED: Client ID of the application. * @param context REQUIRED: Application context. * @return device secret as String, null if the device-key is not available. *///from w w w.ja va 2 s .c o m public static String getDeviceSecret(String username, String userPoolId, Context context) { try { SharedPreferences cipCachedDeviceDetails = context .getSharedPreferences(getDeviceDetailsCacheForUser(username, userPoolId), 0); if (cipCachedDeviceDetails != null && cipCachedDeviceDetails.contains(COGNITO_DEVICE_SECRET)) { return cipCachedDeviceDetails.getString(COGNITO_DEVICE_SECRET, null); } } catch (Exception e) { Log.e(TAG, "Error accessing SharedPreferences" + e.getMessage()); } return null; }