title: How use SharedPreferences to change the font
body: <p>By using this code I want to change font of a textview, but the program doesn't work.<br>
  What I should do?</p>
  
  <pre><code>public class MainActivity extends Activity {
  SharedPreferences shared = getSharedPreferences("Prefs", MODE_PRIVATE);
  SharedPreferences.Editor editor = shared.edit();
  public String fonts = shared.getString("fonts", "BHOMA.ttf");
  @Override
  protected void onCreate(Bundle savedInstanceState) {
      super.onCreate(savedInstanceState);
      setContentView(R.layout.activity_main);
  
  
      setFace();
  }
  protected void setFace()
  {
      TextView txt1 = (TextView)findViewById(R.id.textView1);
       Typeface face = Typeface.createFromAsset(getAssets(), "font/"+fonts+"");
       txt1.setTypeface(face);
  }
  </code></pre>
  
  <p>}</p>
  
  <p>and in prefs.class</p>
  
  <p>public class Prefs extends PreferenceActivity {</p>
  
  <pre><code>@Override
  protected void onCreate(Bundle savedInstanceState) {
          super.onCreate(savedInstanceState);
          SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(this);
  
          String fonts = prefs.getString("fonts", "Tahoma.ttf");
          Boolean b = prefs.getBoolean("FIRSTRUN", true);      
  }
  </code></pre>
  
  <p>}</p>