List of usage examples for android.content SharedPreferences getString
@Nullable String getString(String key, @Nullable String defValue);
From source file:com.lewen.listener.vlc.Util.java
public static float[] getFloatArray(SharedPreferences pref, String key) { float[] array = null; String s = pref.getString(key, null); if (s != null) { try {/* ww w . ja va 2 s. co m*/ JSONArray json = new JSONArray(s); array = new float[json.length()]; for (int i = 0; i < array.length; i++) array[i] = (float) json.getDouble(i); } catch (JSONException e) { e.printStackTrace(); } } return array; }
From source file:com.breadwallet.tools.manager.SharedPreferencesManager.java
public static String getIso(Activity context) { SharedPreferences settingsToGet = context.getSharedPreferences(BRConstants.PREFS_NAME, 0); return settingsToGet.getString(BRConstants.CURRENT_CURRENCY, Currency.getInstance(Locale.getDefault()).getCurrencyCode()); }
From source file:de.schaeuffelhut.android.openvpn.Preferences.java
public final static String getPathToBinary(SharedPreferences sharedPreferences) { String path = sharedPreferences.getString(Preferences.KEY_OPENVPN_PATH_TO_BINARY, null); if (path == null || "".equals(path)) { path = null;/*from w w w . jav a2 s . c o m*/ for (File f : new File[] { new File("/system/xbin/openvpn"), new File("/system/bin/openvpn") }) { if (f.exists()) { path = f.getAbsolutePath(); break; } } } return path; }
From source file:de.schaeuffelhut.android.openvpn.Preferences.java
public final static String getPathToSu(SharedPreferences sharedPreferences) { String path = sharedPreferences.getString(Preferences.KEY_OPENVPN_PATH_TO_SU, null); if (path == null) { for (File f : new File[] { new File("/system/xbin/su"), new File("/system/bin/su"), new File("/sbin/su") }) { if (f.exists()) { path = f.getAbsolutePath(); break; }/*from ww w.ja v a 2s . c om*/ } } return path; }
From source file:com.breadwallet.tools.manager.SharedPreferencesManager.java
public static String getReceiveAddress(Activity context) { SharedPreferences prefs = context.getSharedPreferences(BRConstants.PREFS_NAME, Context.MODE_PRIVATE); return prefs.getString(BRConstants.RECEIVE_ADDRESS, ""); }
From source file:com.breadwallet.tools.manager.SharedPreferencesManager.java
public static String getFirstAddress(Activity context) { SharedPreferences prefs = context.getSharedPreferences(BRConstants.PREFS_NAME, Context.MODE_PRIVATE); return prefs.getString(BRConstants.FIRST_ADDRESS, ""); }
From source file:org.mythtv.service.guide.v25.ProgramGuideHelperV25.java
private static void downloadProgramGuide(final Context context, final LocationProfile locationProfile) throws MythServiceApiRuntimeException, RemoteException, OperationApplicationException { Log.v(TAG, "downloadProgramGuide : enter"); ArrayList<ContentProviderOperation> ops = new ArrayList<ContentProviderOperation>(); ProgramHelperV25.getInstance().deletePrograms(context, locationProfile, ops, ProgramConstants.CONTENT_URI_GUIDE, ProgramConstants.TABLE_NAME_GUIDE); RecordingHelperV25.getInstance().deleteRecordings(context, locationProfile, ops, ContentDetails.GUIDE); DateTime startDownloading = new DateTime(); SharedPreferences sp = PreferenceManager.getDefaultSharedPreferences(context); int downloadDays = Integer.parseInt(sp.getString("preference_program_guide_days", "14")); Log.v(TAG, "downloadProgramGuide : downloadDays=" + downloadDays); DateTime start = new DateTime(DateTimeZone.getDefault()).withTimeAtStartOfDay(); DateTime end = start.plusHours(3);//from w w w .jav a2 s. c o m for (int i = 0; i < ((downloadDays * 24) / 3); i++) { Log.i(TAG, "downloadProgramGuide : starting download for [" + (i + 1) + " of " + ((downloadDays * 24) / 3) + "] " + DateUtils.getDateTimeUsingLocaleFormattingPretty(start, mMainApplication.getDateFormat(), mMainApplication.getClockType()) + ", end time=" + DateUtils.getDateTimeUsingLocaleFormattingPretty(end, mMainApplication.getDateFormat(), mMainApplication.getClockType())); EtagInfoDelegate etag = mEtagDaoHelper.findByEndpointAndDataId(context, locationProfile, "GetProgramGuide", String.valueOf(i)); Log.d(TAG, "downloadProgramGuide : etag=" + etag.getValue()); if (null == etag.getDate() || start.isAfter(etag.getDate())) { Log.v(TAG, "downloadProgramGuide : next mythfilldatabase has passed"); ResponseEntity<ProgramGuide> responseEntity = mMythServicesTemplate.guideOperations() .getProgramGuide(start, end, 1, null, false, etag); if (responseEntity.getStatusCode().equals(HttpStatus.OK)) { Log.i(TAG, "downloadProgramGuide : GetProgramGuide returned 200 OK"); ProgramGuide programGuide = responseEntity.getBody(); if (null != programGuide) { if (null != programGuide) { load(context, locationProfile, programGuide); } } if (null != etag.getValue()) { Log.i(TAG, "downloadProgramGuide : saving etag: " + etag.getValue()); etag.setEndpoint("GetProgramGuide"); etag.setDataId(i); etag.setDate(locationProfile.getNextMythFillDatabase()); etag.setMasterHostname(locationProfile.getHostname()); etag.setLastModified(new DateTime(DateTimeZone.UTC)); mEtagDaoHelper.save(context, locationProfile, etag); } } if (responseEntity.getStatusCode().equals(HttpStatus.NOT_MODIFIED)) { Log.i(TAG, "downloadProgramGuide : GetProgramGuide returned 304 Not Modified"); if (null != etag.getValue()) { Log.i(TAG, "downloadProgramGuide : saving etag: " + etag.getValue()); etag.setLastModified(new DateTime(DateTimeZone.UTC)); mEtagDaoHelper.save(context, locationProfile, etag); } } start = end; end = end.plusHours(3); } else { Log.v(TAG, "downloadProgramGuide : next mythfilldatabase has NOT passed!"); } } Log.i(TAG, "downloadProgramGuide : interval=" + new Interval(startDownloading, new DateTime()).toString()); Log.v(TAG, "downloadProgramGuide : exit"); }
From source file:org.mythtv.service.guide.v26.ProgramGuideHelperV26.java
private static void downloadProgramGuide(final Context context, final LocationProfile locationProfile) throws MythServiceApiRuntimeException, RemoteException, OperationApplicationException { Log.v(TAG, "downloadProgramGuide : enter"); ArrayList<ContentProviderOperation> ops = new ArrayList<ContentProviderOperation>(); ProgramHelperV26.getInstance().deletePrograms(context, locationProfile, ops, ProgramConstants.CONTENT_URI_GUIDE, ProgramConstants.TABLE_NAME_GUIDE); RecordingHelperV26.getInstance().deleteRecordings(context, locationProfile, ops, ContentDetails.GUIDE); DateTime startDownloading = new DateTime(); SharedPreferences sp = PreferenceManager.getDefaultSharedPreferences(context); int downloadDays = Integer.parseInt(sp.getString("preference_program_guide_days", "14")); Log.v(TAG, "downloadProgramGuide : downloadDays=" + downloadDays); DateTime start = new DateTime(DateTimeZone.getDefault()).withTimeAtStartOfDay(); DateTime end = start.plusHours(3);/*from w w w . ja v a 2 s. co m*/ for (int i = 0; i < ((downloadDays * 24) / 3); i++) { Log.i(TAG, "downloadProgramGuide : starting download for [" + (i + 1) + " of " + ((downloadDays * 24) / 3) + "] " + DateUtils.getDateTimeUsingLocaleFormattingPretty(start, mMainApplication.getDateFormat(), mMainApplication.getClockType()) + ", end time=" + DateUtils.getDateTimeUsingLocaleFormattingPretty(end, mMainApplication.getDateFormat(), mMainApplication.getClockType())); EtagInfoDelegate etag = mEtagDaoHelper.findByEndpointAndDataId(context, locationProfile, "GetProgramGuide", String.valueOf(i)); Log.d(TAG, "downloadProgramGuide : etag=" + etag.getValue()); if (null == etag.getDate() || start.isAfter(etag.getDate())) { Log.v(TAG, "downloadProgramGuide : next mythfilldatabase has passed"); ResponseEntity<ProgramGuide> responseEntity = mMythServicesTemplate.guideOperations() .getProgramGuide(start, end, 1, null, false, etag); if (responseEntity.getStatusCode().equals(HttpStatus.OK)) { Log.i(TAG, "downloadProgramGuide : GetProgramGuide returned 200 OK"); ProgramGuide programGuide = responseEntity.getBody(); if (null != programGuide) { if (null != programGuide) { load(context, locationProfile, programGuide); } } if (null != etag.getValue()) { Log.i(TAG, "downloadProgramGuide : saving etag: " + etag.getValue()); etag.setEndpoint("GetProgramGuide"); etag.setDataId(i); etag.setDate(locationProfile.getNextMythFillDatabase()); etag.setMasterHostname(locationProfile.getHostname()); etag.setLastModified(new DateTime(DateTimeZone.UTC)); mEtagDaoHelper.save(context, locationProfile, etag); } } if (responseEntity.getStatusCode().equals(HttpStatus.NOT_MODIFIED)) { Log.i(TAG, "downloadProgramGuide : GetProgramGuide returned 304 Not Modified"); if (null != etag.getValue()) { Log.i(TAG, "downloadProgramGuide : saving etag: " + etag.getValue()); etag.setLastModified(new DateTime(DateTimeZone.UTC)); mEtagDaoHelper.save(context, locationProfile, etag); } } start = end; end = end.plusHours(3); } else { Log.v(TAG, "downloadProgramGuide : next mythfilldatabase has NOT passed!"); } } Log.i(TAG, "downloadProgramGuide : interval=" + new Interval(startDownloading, new DateTime()).toString()); Log.v(TAG, "downloadProgramGuide : exit"); }
From source file:org.mythtv.service.guide.v27.ProgramGuideHelperV27.java
private static void downloadProgramGuide(final Context context, final LocationProfile locationProfile) throws MythServiceApiRuntimeException, RemoteException, OperationApplicationException { Log.v(TAG, "downloadProgramGuide : enter"); ArrayList<ContentProviderOperation> ops = new ArrayList<ContentProviderOperation>(); ProgramHelperV27.getInstance().deletePrograms(context, locationProfile, ops, ProgramConstants.CONTENT_URI_GUIDE, ProgramConstants.TABLE_NAME_GUIDE); RecordingHelperV27.getInstance().deleteRecordings(context, locationProfile, ops, ContentDetails.GUIDE); DateTime startDownloading = new DateTime(); SharedPreferences sp = PreferenceManager.getDefaultSharedPreferences(context); int downloadDays = Integer.parseInt(sp.getString("preference_program_guide_days", "14")); Log.v(TAG, "downloadProgramGuide : downloadDays=" + downloadDays); DateTime start = new DateTime(DateTimeZone.getDefault()).withTimeAtStartOfDay(); DateTime end = start.plusHours(3);/*from ww w . ja v a 2 s .co m*/ for (int i = 0; i < ((downloadDays * 24) / 3); i++) { Log.i(TAG, "downloadProgramGuide : starting download for [" + (i + 1) + " of " + ((downloadDays * 24) / 3) + "] " + DateUtils.getDateTimeUsingLocaleFormattingPretty(start, mMainApplication.getDateFormat(), mMainApplication.getClockType()) + ", end time=" + DateUtils.getDateTimeUsingLocaleFormattingPretty(end, mMainApplication.getDateFormat(), mMainApplication.getClockType())); EtagInfoDelegate etag = mEtagDaoHelper.findByEndpointAndDataId(context, locationProfile, "GetProgramGuide", String.valueOf(i)); Log.d(TAG, "downloadProgramGuide : etag=" + etag.getValue()); if (null == etag.getDate() || start.isAfter(etag.getDate())) { Log.v(TAG, "downloadProgramGuide : next mythfilldatabase has passed"); ResponseEntity<ProgramGuide> responseEntity = mMythServicesTemplate.guideOperations() .getProgramGuide(start, end, 1, null, false, etag); if (responseEntity.getStatusCode().equals(HttpStatus.OK)) { Log.i(TAG, "downloadProgramGuide : GetProgramGuide returned 200 OK"); ProgramGuide programGuide = responseEntity.getBody(); if (null != programGuide) { if (null != programGuide) { load(context, locationProfile, programGuide); } } if (null != etag.getValue()) { Log.i(TAG, "downloadProgramGuide : saving etag: " + etag.getValue()); etag.setEndpoint("GetProgramGuide"); etag.setDataId(i); etag.setDate(locationProfile.getNextMythFillDatabase()); etag.setMasterHostname(locationProfile.getHostname()); etag.setLastModified(new DateTime(DateTimeZone.UTC)); mEtagDaoHelper.save(context, locationProfile, etag); } } if (responseEntity.getStatusCode().equals(HttpStatus.NOT_MODIFIED)) { Log.i(TAG, "downloadProgramGuide : GetProgramGuide returned 304 Not Modified"); if (null != etag.getValue()) { Log.i(TAG, "downloadProgramGuide : saving etag: " + etag.getValue()); etag.setLastModified(new DateTime(DateTimeZone.UTC)); mEtagDaoHelper.save(context, locationProfile, etag); } } start = end; end = end.plusHours(3); } else { Log.v(TAG, "downloadProgramGuide : next mythfilldatabase has NOT passed!"); } } Log.i(TAG, "downloadProgramGuide : interval=" + new Interval(startDownloading, new DateTime()).toString()); Log.v(TAG, "downloadProgramGuide : exit"); }
From source file:com.breadwallet.tools.manager.SharedPreferencesManager.java
public static String getDeviceId(Activity context) { SharedPreferences settingsToGet = context.getSharedPreferences(BRConstants.PREFS_NAME, 0); String deviceId = settingsToGet.getString(BRConstants.USER_ID, ""); if (deviceId.isEmpty()) setDeviceId(context, UUID.randomUUID().toString()); return (settingsToGet.getString(BRConstants.USER_ID, "")); }