Rietveld Code Review Tool
Help | Bug tracker | Discussion group | Source code

Unified Diff: adblockplussbrowser/src/main/java/org/adblockplus/sbrowser/contentblocker/util/SharedPrefsUtils.java

Issue 29760569: Issue 6238 - Download/store notifications.json (Closed)
Patch Set: Created May 15, 2018, 9:57 a.m.
Use n/p to move between diff chunks; N/P to move between comments.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: adblockplussbrowser/src/main/java/org/adblockplus/sbrowser/contentblocker/util/SharedPrefsUtils.java
===================================================================
--- a/adblockplussbrowser/src/main/java/org/adblockplus/sbrowser/contentblocker/util/SharedPrefsUtils.java
+++ b/adblockplussbrowser/src/main/java/org/adblockplus/sbrowser/contentblocker/util/SharedPrefsUtils.java
@@ -59,16 +59,35 @@ public class SharedPrefsUtils
return preferences.getInt(context.getString(keyResId), defValue);
}
catch (ClassCastException e)
{
return defValue;
}
}
+ public static void putLong(final Context context, final int keyResId, final long value)
+ {
+ final SharedPreferences.Editor editor = getDefaultSharedPreferences(context).edit();
+ editor.putLong(context.getString(keyResId), value).apply();
+ }
+
+ public static long getLong(final Context context, final int keyResId, final long defValue)
+ {
+ final SharedPreferences preferences = getDefaultSharedPreferences(context);
+ try
+ {
+ return preferences.getLong(context.getString(keyResId), defValue);
+ }
+ catch (final ClassCastException e)
+ {
+ return defValue;
+ }
+ }
+
public static void putString(Context context, int keyResId, String value)
{
final SharedPreferences.Editor editor = getDefaultSharedPreferences(context).edit();
editor.putString(context.getString(keyResId), value).apply();
}
public static String getString(Context context, int keyResId, String defValue)
{

Powered by Google App Engine
This is Rietveld