java - Null Pointer Exception in FileOutputStream -


I am trying to run a simple program using FileOutputStream. When I run this program, the app shows the message "Unfortunately Closed App" Logger NullPointerException Displays What's Wrong in My Code ??

  package com.example.storageinternal; Import java.io.phileNotFoundException; Import java.io.FileOutputStream; Import java.io.IOException; Importroid.os.Bundle; Import android App Import android.content.Context; Import android.content.Intent; Import android.view.Menu; Import android.view.View; Import android.view.View.OnClickListener; Import android.widget.Button; Import android.widget.EditText; Public class increases main activity activity (personal editing tag editing name, editemail; personal button save; @ override protected zero creation (bundle saved instenestate) {super.naught (savedinstenstate); setContentView (R.layout.activity_main); Editname = (EditText) findViewById (RID.EditTem); Editemail = (Edit Text) SearchVBIID (RID Edit Mail); Save.setOnClickListener (New OnClickListener) {@Override Public Zero Click Click (see ) / TODO Auto-generated method stub string name = editname.getText (). ToString (); string Imelstring = editemail.getText (). ToString (); FileOutputStream fos = null; try {fos = openFileOutput ( "Mystorage", Context.MODE_PRIVATE);} catch (FileNotFoundException e) {// TODO auto-generated holding Try block e.printStackTrace ();} {fos.write () Namestring.getBytes ());} catch (IOException e) { // TODO Auto-generated catch block e.printStackTrace ()}} {fos.write (emailstring.getBytes ())}} catch (IOException e) {/ / TODO Auto-generated holding block e.printStackTrace (); } Finally {if (fos! = Null) {try {fos.close (}}} Catch (IOException e) {// TODO auto generated blocking block e.printStackTrace ();}}}}); }} @ Override Public Boolean On Crate Option Menu (Menu Menu) {// Increase Menu; It adds the item to the Action Bar if it exists GetMenuInflater (). Fulao (R. menu menu, menu); Back true; }    

missing button missing OnCreate () .

Before applying your code, start the button onClickListener . save button = (button) findViewById (R.id.button);

Comments

Popular posts from this blog

Pass DB Connection parameters to a Kettle a.k.a PDI table Input step dynamically from Excel -

multithreading - PhantomJS-Node in a for Loop -

c++ - MATLAB .m file to .mex file using Matlab Compiler -