use of android.content.SharedPreferences in project platform_frameworks_base by android.
the class NetworkActivity method loadXmlFromNetwork.
// Uploads XML from stackoverflow.com, parses it, and combines it with
// HTML markup. Returns HTML string.
private String loadXmlFromNetwork(String urlString) throws XmlPullParserException, IOException {
InputStream stream = null;
StackOverflowXmlParser stackOverflowXmlParser = new StackOverflowXmlParser();
List<Entry> entries = null;
String title = null;
String url = null;
String summary = null;
Calendar rightNow = Calendar.getInstance();
DateFormat formatter = new SimpleDateFormat("MMM dd h:mmaa");
// Checks whether the user set the preference to include summary text
SharedPreferences sharedPrefs = PreferenceManager.getDefaultSharedPreferences(this);
boolean pref = sharedPrefs.getBoolean("summaryPref", false);
StringBuilder htmlString = new StringBuilder();
htmlString.append("<h3>" + getResources().getString(R.string.page_title) + "</h3>");
htmlString.append("<em>" + getResources().getString(R.string.updated) + " " + formatter.format(rightNow.getTime()) + "</em>");
try {
stream = downloadUrl(urlString);
entries = stackOverflowXmlParser.parse(stream);
// Makes sure that the InputStream is closed after the app is
// finished using it.
} finally {
if (stream != null) {
stream.close();
}
}
// a text summary.
for (Entry entry : entries) {
htmlString.append("<p><a href='");
htmlString.append(entry.link);
htmlString.append("'>" + entry.title + "</a></p>");
// adds it to the display.
if (pref) {
htmlString.append(entry.summary);
}
}
return htmlString.toString();
}
use of android.content.SharedPreferences in project platform_frameworks_base by android.
the class PrintActivity method setUserPrinted.
/**
* Remember that the user printed a document
*/
private void setUserPrinted() {
SharedPreferences preferences = getSharedPreferences(HAS_PRINTED_PREF, MODE_PRIVATE);
if (!preferences.getBoolean(HAS_PRINTED_PREF, false)) {
SharedPreferences.Editor edit = preferences.edit();
edit.putBoolean(HAS_PRINTED_PREF, true);
edit.apply();
}
}
use of android.content.SharedPreferences in project freeline by alibaba.
the class FreelineCore method applyDynamicDex.
public static boolean applyDynamicDex(String dexFileStr, String dexOptDir) {
Log.i(TAG, "apply dynamicDex " + dexFileStr);
SharedPreferences sp = getDynamicInfoSp();
SharedPreferences.Editor editor = sp.edit();
//editor.putString(DYNAMIC_INFO_DEX_PATH_KEY, dexFileStr);
editor.putString(DYNAMIC_INFO_DEX_DIR_KEY, dexFileStr);
editor.putString(DYNAMIC_INFO_OPT_PATH_KEY, dexOptDir);
editor.commit();
return true;
}
use of android.content.SharedPreferences in project freeline by alibaba.
the class FreelineCore method saveDynamicResInfo.
/***
* packagid + newResPath
*
* @param dynamicRes
*/
public static boolean saveDynamicResInfo(HashMap<String, String> dynamicRes) {
boolean result = true;
SharedPreferences sp = getDynamicInfoSp();
SharedPreferences.Editor editor = sp.edit();
for (String packageId : dynamicRes.keySet()) {
String pendingPath = dynamicRes.get(packageId);
editor.putString(getDynamicResPathKey(packageId), pendingPath);
}
editor.commit();
Log.i(TAG, "apply res :" + dynamicRes);
injectResources();
return result;
}
use of android.content.SharedPreferences in project dynamic-load-apk by singwhatiwanna.
the class DLConfigs method setSoLastModifiedTime.
@TargetApi(Build.VERSION_CODES.HONEYCOMB)
public static void setSoLastModifiedTime(Context cxt, String soName, long time) {
SharedPreferences prefs = cxt.getSharedPreferences(DLConstants.PREFERENCE_NAME, Context.MODE_PRIVATE | Context.MODE_MULTI_PROCESS);
prefs.edit().putLong(soName, time).apply();
}
Aggregations