title: I am unable to start a new activity through Intent in Android
body: <p>Unable to start new activity(i.e. OpenItDude.class).</p>
  
  <p>My app is about saving/writing a .txt file in external storage and then reading it .</p>
  
  <p>All works fine but when I press open button the app crashes. Save button works absolutely fine. And when I press open button after pressing save button app doesn't crashes but nothing happens... Unable to start new activity - OpenItDude.class</p>
  
  <p>MainActivity.class</p>
  
  <pre><code>public class MainActivity extends Activity {
  
  EditText message,fileName;
  Button save,open;
  String msg,file;
  
  
  @Override
  protected void onCreate(Bundle savedInstanceState) {
      super.onCreate(savedInstanceState);
  
      setIt("","");
      final Intent ourIntent = new Intent(MainActivity.this,OpenItDude.class);
      save.setOnClickListener(new View.OnClickListener() {
          @Override
          public void onClick(View v) {
              msg = message.getText().toString();
              file = fileName.getText().toString();
              save(msg,file);
  
          }
      });
  
      open.setOnClickListener(new View.OnClickListener() {
          @Override
          public void onClick(View v) {
  
              startActivity(ourIntent);
  
          }
      });
  
  
  
  }
  
  void save(String msg1,String file1)
  {
  
      try
      {
          File notes = new File(Environment.getExternalStorageDirectory(), "Notes");
          if (!notes.exists()) {
              notes.mkdirs();
          }
          File gpxfile = new File(notes, file1+".txt");
          FileWriter writer = new FileWriter(gpxfile);
          writer.append(msg1);
          writer.flush();
          writer.close();
          Toast.makeText(getApplicationContext(), "Saved !",
                  Toast.LENGTH_SHORT).show();
      }
      catch(IOException e)
      {
          e.printStackTrace();
          Toast.makeText(getApplicationContext(), "File Not Saved !",
                  Toast.LENGTH_SHORT).show();
      }
      setIt("", "");
  }
  
  void setIt(String name,String message){
      setContentView(R.layout.activity_main);
  
      fileName = (EditText)findViewById(R.id.filename);
      this.message=(EditText)findViewById(R.id.editText);
      save= (Button) findViewById(R.id.button);
      open = (Button) findViewById(R.id.openbtn);
  
      fileName.setText(name);
      this.message.setText(message);
  
  }
  
  @Override
  protected void onPause() {
      super.onPause();
      finish();
  }
  }
  </code></pre>
  
  <p>OpenItDude.class</p>
  
  <pre><code>public class OpenItDude extends Activity {
  
  Button opens, save;
  AutoCompleteTextView actv;
  String fileToOpen,MSG,FILE;
  EditText FN, ET;
  
  @Override
  protected void onCreate(Bundle savedInstanceState) {
      super.onCreate(savedInstanceState);
      setContentView(R.layout.openfilelayout);
  
      opens = (Button) findViewById(R.id.button2open);
      actv = (AutoCompleteTextView) findViewById(R.id.autoCompleteTextView);
      FN = (EditText) findViewById(R.id.FN);
      ET = (EditText) findViewById(R.id.ET);
      save = (Button) findViewById(R.id.save);
  
      opens.setOnClickListener(new View.OnClickListener() {
          @Override
          public void onClick(View v) {
              //make open button logic
              //Work is pending...
              fileToOpen = actv.getText().toString();
              try {
                  FileInputStream fin = openFileInput(fileToOpen);
                  int c;
                  String temp = "";
  
                  while ((c = fin.read()) != -1) {
                      temp = temp + Character.toString((char) c);
                  }
                  setContentView(R.layout.open_ultimate);
                  FN.setText(fileToOpen);
                  ET.setText(temp);
                  Toast.makeText(getBaseContext(), "File read !", Toast.LENGTH_SHORT).show();
  
  
  
              } catch (Exception e) {
                  e.printStackTrace();
              }
  
          }
      });
  
      save.setOnClickListener(new View.OnClickListener() {
          @Override
          public void onClick(View v) {
              MSG = ET.getText().toString();
              FILE = FN.getText().toString();
              save(MSG,FILE);
  
          }
      });
  
  }
  
  void save(String msg1,String file1)
  {
  
      try
      {
          File notes = new File(Environment.getExternalStorageDirectory(), "Notes");
          if (!notes.exists()) {
              notes.mkdirs();
          }
          File gpxfile = new File(notes, file1+".txt");
          FileWriter writer = new FileWriter(gpxfile);
          writer.append(msg1);
          writer.flush();
          writer.close();
          Toast.makeText(getApplicationContext(), "Saved !",
                  Toast.LENGTH_SHORT).show();
      }
      catch(IOException e)
      {
          e.printStackTrace();
          Toast.makeText(getApplicationContext(), "File Not Saved !",
                  Toast.LENGTH_SHORT).show();
      }
      Intent myIntent = new Intent(OpenItDude.this,MainActivity.class);
      startActivity(myIntent);
  }
  
  @Override
  protected void onPause() {
      super.onPause();
      finish();
  }
  }`
  </code></pre>
  
  <p>Manifest.xml</p>
  
  <pre><code>&lt;?xml version="1.0" encoding="utf-8"?&gt;
  &lt;manifest xmlns:android="http://schemas.android.com/apk/res/android"
  package="com.example.corei5.noteitdown" &gt;
  
  &lt;application
      android:allowBackup="true"
      android:icon="@mipmap/ic_launcher"
      android:label="@string/app_name"
      android:supportsRtl="true"
      android:theme="@style/AppTheme" &gt;
      &lt;activity android:name=".MainActivity" &gt;
          &lt;intent-filter&gt;
              &lt;action android:name="android.intent.action.MAIN" /&gt;
  
              &lt;category android:name="android.intent.category.LAUNCHER" /&gt;
          &lt;/intent-filter&gt;
      &lt;/activity&gt;
      &lt;activity android:name=".OpenItDude"&gt;
  
          &lt;/activity&gt;
  &lt;/application&gt;
  &lt;uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" /&gt;
  &lt;uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE" /&gt;
  
  &lt;/manifest&gt;
  </code></pre>