• After 15+ years, we've made a big change: Android Forums is now Early Bird Club. Learn more here.

Apps Reading from file

WillDot

Lurker
Hey guys.

I have to hand in my application for my uni project on Thursday and I have come across a problem.

I need to be able to save the string value from an "editText" when I click on the save button. Then when I re-open the application, the "editText" will automatically retrieve the save file.

I have got the following code so far.

Code:
public class AppMain extends Activity {
	
	TextView textOut;
	EditText getInputMain;
	String textOutput = textOut.getText().toString();

	@Override
	public void onCreate(Bundle savedInstanceState){
		super.onCreate(savedInstanceState);
		setContentView(R.layout.main_large);
		

		FileInputStream fis =openFileInput(textOutput);
		ObjectInputStream ois = new ObjectInputStream(fis);
		flow f = (Flow) ois.readObject();
		
		//Save button
		
		textOut= (TextView)findViewById(R.id.input);
		textOut = (EditText) findViewById(R.id.input);
		Button saveButton = (Button) findViewById(R.id.saveButton);
		saveButton.setOnClickListener(new OnClickListener(){
			
			public void onClick(View v){
				textOut.toString();
				
				//closing the keyboard
				InputMethodManager imm =(InputMethodManager)getSystemService(Context.INPUT_METHOD_SERVICE);
				imm.hideSoftInputFromWindow(textOut.getWindowToken(),0);
				
				//saving to sd card
			
				FileOutputStream fos = openFileOutput(textOutput,Context.MODE_PRIVATE);
				ObjectOutputStream oos = new ObjectOutputStream(fos);
				oos.writeObject(textOut); oos.close();
				
										
										}
															});

A) Is the write to file bit correct?
B) The part where I read from file says that "flow" isn't acceptable. What am I doing wrong?

Cheers guys. I really need help to get this finished by Thursday :eek:
 
Back
Top Bottom