Search in sources :

Example 51 with SharedPreferences

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();
}
Also used : Entry(com.example.android.networkusage.StackOverflowXmlParser.Entry) SharedPreferences(android.content.SharedPreferences) InputStream(java.io.InputStream) Calendar(java.util.Calendar) SimpleDateFormat(java.text.SimpleDateFormat) DateFormat(java.text.DateFormat) SimpleDateFormat(java.text.SimpleDateFormat)

Example 52 with SharedPreferences

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();
    }
}
Also used : SharedPreferences(android.content.SharedPreferences)

Example 53 with SharedPreferences

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;
}
Also used : SharedPreferences(android.content.SharedPreferences)

Example 54 with SharedPreferences

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;
}
Also used : SharedPreferences(android.content.SharedPreferences)

Example 55 with SharedPreferences

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();
}
Also used : SharedPreferences(android.content.SharedPreferences) TargetApi(android.annotation.TargetApi)

Aggregations

SharedPreferences (android.content.SharedPreferences)1762 Intent (android.content.Intent)221 View (android.view.View)110 Editor (android.content.SharedPreferences.Editor)100 TextView (android.widget.TextView)74 ArrayList (java.util.ArrayList)67 Context (android.content.Context)59 PendingIntent (android.app.PendingIntent)57 File (java.io.File)57 IOException (java.io.IOException)56 Bundle (android.os.Bundle)45 JSONException (org.json.JSONException)41 JSONObject (org.json.JSONObject)41 DialogInterface (android.content.DialogInterface)37 AdapterView (android.widget.AdapterView)34 ImageView (android.widget.ImageView)34 ListView (android.widget.ListView)34 SuppressLint (android.annotation.SuppressLint)33 JSONArray (run.wallet.common.json.JSONArray)33 ComponentName (android.content.ComponentName)31