title: unfortunately app has stopped , android
body: <p>i have given the code here . and when i run it in genymotion it just stops working. please help .
  i dont see any display in logcat also . it remains blank and the emulator only shows an error that is "unfortulately, SharedprefrencEexample has stoped working. and the app dont even starts. so i dont get any clue of what might be the error in this code . 
  here i have used the reference creation at the start and i think it might be the error. so please do see the code and help me.
  thanks.</p>
  
  <p><B>Main_Activity</B></p>
  
  <pre><code>package com.example.sharedprefrenceexample;
  
  import android.app.Activity;
  import android.content.Intent;
  import android.content.SharedPreferences;
  import android.os.Bundle;
  import android.view.Menu;
  import android.view.MenuItem;
  import android.view.View;
  import android.view.View.OnClickListener;
  import android.widget.Button;
  import android.widget.EditText;
  
  public class MainActivity extends Activity {
  
  EditText name,phone,email;
  Button submit;
  Intent intent;
  SharedPreferences sharedPreferences;
  SharedPreferences.Editor editor;
  
  @Override
  protected void onCreate(Bundle savedInstanceState) {
      super.onCreate(savedInstanceState);
      setContentView(R.layout.activity_main);
  
      name=(EditText) findViewById(R.id.editText1);
      phone=(EditText) findViewById(R.id.editText2);
      email=(EditText) findViewById(R.id.editText3);
      submit=(Button) findViewById(R.id.button1);
  
      submit.setText("@string/button_name_activity_one");
      name.setHint("name");
      phone.setHint("phone");
      email.setHint("email id");
  
      sharedPreferences=getSharedPreferences("@string/database_name", MODE_PRIVATE);
      editor=sharedPreferences.edit();
  
      submit.setOnClickListener(new OnClickListener() {
  
          @Override
          public void onClick(View arg0) {
              // TODO Auto-generated method stub
              editor.putString("name", name.getText().toString());
              editor.putString("phone", phone.getText().toString());
  
              editor.commit();
  
              intent=new Intent(MainActivity.this,Secondactivity.class);
              intent.putExtra("email", email.getText().toString());
  
              startActivity(intent);
          }
      });
  }
  
  @Override
  public boolean onCreateOptionsMenu(Menu menu) {
      // Inflate the menu; this adds items to the action bar if it is present.
      getMenuInflater().inflate(R.menu.main, menu);
      return true;
  }
  
  @Override
  public boolean onOptionsItemSelected(MenuItem item) {
      // Handle action bar item clicks here. The action bar will
      // automatically handle clicks on the Home/Up button, so long
      // as you specify a parent activity in AndroidManifest.xml.
      int id = item.getItemId();
      if (id == R.id.action_settings) {
          return true;
      }
      return super.onOptionsItemSelected(item);
  }
  }
  </code></pre>
  
  <p><b>activity_main.xml</b></p>
  
  <pre><code>   &lt;RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
  xmlns:tools="http://schemas.android.com/tools"
  android:layout_width="match_parent"
  android:layout_height="match_parent"
  android:paddingBottom="@dimen/activity_vertical_margin"
  android:paddingLeft="@dimen/activity_horizontal_margin"
  android:paddingRight="@dimen/activity_horizontal_margin"
  android:paddingTop="@dimen/activity_vertical_margin"
  tools:context="com.example.sharedprefrenceexample.MainActivity" &gt;
  
  &lt;EditText
      android:id="@+id/editText1"
      android:layout_width="wrap_content"
      android:layout_height="wrap_content"
      android:layout_alignParentLeft="true"
      android:layout_alignParentTop="true"
      android:ems="10" &gt;
  
      &lt;requestFocus /&gt;
  &lt;/EditText&gt;
  
  &lt;EditText
      android:id="@+id/editText2"
      android:layout_width="wrap_content"
      android:layout_height="wrap_content"
      android:layout_alignParentLeft="true"
      android:layout_below="@+id/editText1"
      android:ems="10"
      android:inputType="numberPassword" /&gt;
  
  &lt;EditText
      android:id="@+id/editText3"
      android:layout_width="wrap_content"
      android:layout_height="wrap_content"
      android:layout_alignLeft="@+id/editText2"
      android:layout_below="@+id/editText2"
      android:ems="10"
      android:inputType="textEmailAddress" /&gt;
  
  &lt;Button
      android:id="@+id/button1"
      android:layout_width="wrap_content"
      android:layout_height="wrap_content"
      android:layout_alignParentBottom="true"
      android:layout_alignParentRight="true"
      android:text="@string/button_name_activity_one" /&gt;
  
  &lt;/RelativeLayout&gt;
  </code></pre>
  
  <p><b>secondactivity</b></p>
  
  <pre><code>package com.example.sharedprefrenceexample;
  
  import android.app.Activity;
  import android.content.Intent;
  import android.content.SharedPreferences;
  import android.os.Bundle;
  import android.view.Menu;
  import android.view.MenuItem;
  import android.widget.TextView;
  
  public class Secondactivity extends Activity {
  
  TextView result;
  SharedPreferences sharedPreferences;
  Intent intent;
  
  @Override
  protected void onCreate(Bundle savedInstanceState) {
      super.onCreate(savedInstanceState);
      setContentView(R.layout.activity_secondactivity);
  
      result=(TextView) findViewById(R.id.textView1);
  
      sharedPreferences=getSharedPreferences("database", MODE_PRIVATE);
      String res = null;
      res=res+sharedPreferences.getString("name", "no name");
      res=res+sharedPreferences.getString("phone", "no phone");
  
      intent=getIntent();
  
      res=res+intent.getStringExtra("email");
  
      result.setText(res);
  }
  
  @Override
  public boolean onCreateOptionsMenu(Menu menu) {
      // Inflate the menu; this adds items to the action bar if it is present.
      getMenuInflater().inflate(R.menu.secondactivity, menu);
      return true;
  }
  
  @Override
  public boolean onOptionsItemSelected(MenuItem item) {
      // Handle action bar item clicks here. The action bar will
      // automatically handle clicks on the Home/Up button, so long
      // as you specify a parent activity in AndroidManifest.xml.
      int id = item.getItemId();
      if (id == R.id.action_settings) {
          return true;
      }
      return super.onOptionsItemSelected(item);
  }
  }
  </code></pre>
  
  <p><b>activity_secondactivity.xml</b></p>
  
  <pre><code>&lt;RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
  xmlns:tools="http://schemas.android.com/tools"
  android:layout_width="match_parent"
  android:layout_height="match_parent"
  android:paddingBottom="@dimen/activity_vertical_margin"
  android:paddingLeft="@dimen/activity_horizontal_margin"
  android:paddingRight="@dimen/activity_horizontal_margin"
  android:paddingTop="@dimen/activity_vertical_margin"
  tools:context="com.example.sharedprefrenceexample.Secondactivity" &gt;
  
  &lt;TextView
      android:id="@+id/textView1"
      android:layout_width="wrap_content"
      android:layout_height="wrap_content"
      android:layout_alignParentLeft="true"
      android:layout_alignParentTop="true"
      android:text="Large Text"
      android:textAppearance="?android:attr/textAppearanceLarge" /&gt;
  
  &lt;/RelativeLayout&gt;
  </code></pre>