Java tutorial
//package com.java2s; /* * The MIT License (MIT) * Copyright (c) 2014 longkai * The software shall be used for good, not evil. */ import android.content.SharedPreferences; import android.graphics.Typeface; import java.io.File; public class Main { public static Typeface getTypeface(SharedPreferences pref, String key, String defaultTypeface) { Typeface typeface = null; String fontPath = pref.getString(key, null); if (fontPath == null || fontPath.equals(defaultTypeface)) { return null; } else { try { typeface = Typeface.createFromFile(new File(fontPath)); } catch (Exception e) { } } return typeface; } }