package test.package; import java.io.File; import java.io.OutputStreamWriter; import android.app.Activity; import android.content.Intent; import android.os.Bundle; import android.widget.Toast; public class MainActivity extends Activity { @Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); Toast.makeText(this, "Before Activity Main", Toast.LENGTH_SHORT).show(); setContentView(R.layout.activity_main); Toast.makeText(this, "After Activity Main", Toast.LENGTH_SHORT).show(); } { OutputStreamWriter out; try { Toast.makeText(this, "Starting...", Toast.LENGTH_SHORT).show(); File path=new File(getFilesDir(),"raw"); File mypath=new File(path,"status"); if (!mypath.exists()) { out = new OutputStreamWriter(openFileOutput( mypath.getAbsolutePath() , MODE_PRIVATE)); out.write("If you see this - It worked"); out.close(); Toast.makeText(this, "File Written - Displaying Result", Toast.LENGTH_SHORT).show(); }} catch (Exception e) { Toast.makeText(this, "Error on MainActivity", Toast.LENGTH_LONG).show(); e.printStackTrace(); } finally { Intent openStartingPoint = new Intent("test.package.Serve2"); startActivity(openStartingPoint); } } }