Error after Building in device used
<p>I have write a code for storing data and for that i have SharedPreferences..but the case is that there is no error shown in the code but when i run the app in my nexus s device it not building..i am sending the code could anyone please check it..</p>

<p>code for xml..</p>

<pre><code>&lt;?xml version="1.0" encoding="utf-8"?&gt;
&lt;LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
   android:orientation="vertical"
   android:layout_width="fill_parent"
   android:layout_height="fill_parent"
   &gt;
&lt;TextView 
   android:layout_width="fill_parent"
   android:layout_height="wrap_content"
   android:text="@string/hello"
   /&gt;
&lt;TextView 
   android:layout_width="fill_parent"
   android:layout_height="wrap_content"
   android:text="Saved Mem 1:"
   /&gt;
&lt;TextView 
   android:id="@+id/savedmem1"
   android:layout_width="fill_parent"
   android:layout_height="wrap_content"
   /&gt;
&lt;TextView 
   android:layout_width="fill_parent"
   android:layout_height="wrap_content"
   android:text="Saved Mem 2:"
   /&gt;
&lt;TextView 
   android:id="@+id/savedmem2"
   android:layout_width="fill_parent"
   android:layout_height="wrap_content"
   /&gt;
&lt;EditText
   android:id="@+id/edittext1"
   android:layout_width="fill_parent"
   android:layout_height="wrap_content"
   /&gt;
&lt;Button
   android:id="@+id/save_mem1"
   android:layout_width="wrap_content"
   android:layout_height="wrap_content"
   android:text="Save Mem 1"
   /&gt;
&lt;EditText
   android:id="@+id/edittext2"
   android:layout_width="fill_parent"
   android:layout_height="wrap_content"
   /&gt;
&lt;Button
   android:id="@+id/save_mem2"
   android:layout_width="wrap_content"
   android:layout_height="wrap_content"
   android:text="Save Mem 2"
   /&gt;
&lt;/LinearLayout&gt;
</code></pre>

<p>code for java:</p>

<pre><code>package com.examples.storedata;

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

public class Activity1 extends Activity implements OnClickListener {

EditText editText1, editText2;
TextView textSavedMem1, textSavedMem2;
Button buttonSaveMem1, buttonSaveMem2;

   public void onCreate(Bundle savedInstanceState) 
   {
       super.onCreate(savedInstanceState);
       setContentView(R.layout.main); 
       textSavedMem1 = (TextView)findViewById(R.id.savedmem1);
       textSavedMem2 = (TextView)findViewById(R.id.savedmem2);
       editText1 = (EditText)findViewById(R.id.edittext1);
       editText2 = (EditText)findViewById(R.id.edittext2);
       buttonSaveMem1 = (Button)findViewById(R.id.save_mem1);
       buttonSaveMem2 = (Button)findViewById(R.id.save_mem2);

       buttonSaveMem1.setOnClickListener(this);
       buttonSaveMem2.setOnClickListener(this);

       LoadPreferences();
   }

  public void onClick1(View arg0) 
  {

       SavePreferences("MEM1", editText1.getText().toString());
       LoadPreferences();
  }
  public void onClick(View arg0) 
  {

       SavePreferences("MEM2", editText2.getText().toString());
       LoadPreferences();
  }

   private void SavePreferences(String key, String value)
   {
        SharedPreferences sharedPreferences = getPreferences(MODE_PRIVATE);
        SharedPreferences.Editor editor = sharedPreferences.edit();
        editor.putString(key, value);
        editor.commit();
   }

   private void LoadPreferences()
   {
        SharedPreferences sharedPreferences = getPreferences(MODE_PRIVATE);
        String strSavedMem1 = sharedPreferences.getString("MEM1", "");
        String strSavedMem2 = sharedPreferences.getString("MEM2", "");
        textSavedMem1.setText(strSavedMem1);
        textSavedMem2.setText(strSavedMem2);
   }
}
</code></pre>
