Java tutorial
//package com.java2s; //License from project: Open Source License import android.content.Context; import android.preference.PreferenceManager; public class Main { private static final int DEFAULT_FONTSIZE = 14; public static int getFontSize(Context context) { try { int fontSize = Integer .parseInt(PreferenceManager.getDefaultSharedPreferences(context).getString("fontSize", "14")); if (fontSize > 2) return fontSize; } catch (NumberFormatException e) { } return DEFAULT_FONTSIZE; } }