FileIO
public class MainActivity extends Activity { private static final String FILE_NAME = "file_output.txt"; private Button bt1, bt2; private TextView tv; private EditText et; @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_main); bt1 = (Button) findViewById(R.id.bt1); bt2 = (Button) findViewById(R.id.bt2); tv = (TextView) findViewById(R.id.tv); et = (EditText) findViewById(R.id.et); bt1.setOnClickListener(new OnClickListener() { @Override public void onClick(View v) { // TODO Auto-generated method stub savedInputDatatoFile(); } }); bt2.setOnClickListener(new OnClickListener() { @Override public void onClick(View v) { // TODO Auto-generated method stub loadDataFromFile(); } }); } private void savedInputDatatoFile() { try { FileOutputStream fos = openFileOutput(FILE_NAME, Context.MODE_PRIVATE); String inputFileContent = et.getText().toString(); fos.write(inputFileContent.getBytes()); fos.close(); } catch (FileNotFoundException e) { e.printStackTrace(); } catch (IOException e) { e.printStackTrace(); } } private void loadDataFromFile() { try { FileInputStream fis = openFileInput(FILE_NAME); byte[] buffer = new byte[1024]; fis.read(buffer); String fileContent = EncodingUtils.getString(buffer, "UTF-8"); tv.setText(fileContent); } catch (FileNotFoundException e) { e.printStackTrace(); } catch (IOException e) { e.printStackTrace(); } } }