Show a dialog with all the shared preferences
/** Show a dialog with all the shared preferences */
private void ShowSharedPreferencesDialog(Context mContext) {
// Date format
DateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss", Locale.getDefault());
Calendar c = Calendar.getInstance();
// Retrieve the preferences values
String message = "SHARED PREFERENCES:\n";
SharedPreferences shPrefs = getSharedPreferences("YOUR_KEYWORD", MODE_PRIVATE);
Map<String,?> keys = shPrefs.getAll();
for(Map.Entry<String,?> entry : keys.entrySet()){
message += "["+entry.getKey() + "] " + entry.getValue().toString() + " \n";
}
// Show the dialog box
AlertDialog dialog = new AlertDialog.Builder(mContext).setMessage(message).show();
TextView textView = (TextView) dialog.findViewById(android.R.id.message);
textView.setTextSize(12);
}
Written by Daniele Rigo
Related protips
Have a fresh tip? Share with Coderwall community!
Post
Post a tip
Best
#Android
Authors
Related Tags
#android
Sponsored by #native_company# — Learn More
#native_title#
#native_desc#