package gr.mybook.mypreferences;

import android.app.Activity;
import android.content.SharedPreferences;
import android.os.Bundle;
import android.view.View;
import android.widget.Button;
import android.widget.EditText;

public class MyPreferences extends Activity {
	EditText etxt;
	Button btn;
	SharedPreferences prefs;
	String fileName = "myPrefs";

	private static final String KEY_1="size";
	private static final String KEY_2="field";
	private static final float defValue_1 = 18;
	private static final String defValue_2 = "NO TEXT SAVED";


    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.load);
		etxt=(EditText)findViewById(R.id.text2);
		btn=(Button)findViewById(R.id.btn2);
    }

	public void load(View v) {
		// create preferences object
		prefs=getSharedPreferences(fileName,MODE_PRIVATE);
		// get font size from file
		float fontSize = prefs.getFloat(KEY_1, defValue_1);
		etxt.setText(prefs.getString(KEY_2, defValue_2));
		etxt.setTextSize(fontSize);
	}
}
