0

Hy!!

I have a login form in my app, but i want to save/restore the textfile internal in the app not on the internal phone memory.

Are there some code snippets?

I made a internal file saving/restoring but it don't work.

if (cb.isChecked())
                {
                    File file = new File("/mmt/sdcard/login.skip");
                    Writer output = null;
                    try
                    {
                         output = new BufferedWriter(new FileWriter(file));
                            output.write(etuser.getText().toString()+ ";" + etpw.getText().toString());
                            output.close();
                    }
                    catch (Exception e) {
                        // TODO: handle exception
                    }

                }

File file = new File("/mmt/sdcard/login.skip");
    if(file.exists())
    {   try
        {
          BufferedReader input =  new BufferedReader(new FileReader(file));
          while (( line = input.readLine()) != null){
             line2 = line;
            }
          etuser.setText(line2.split(";")[0]);
          etpw.setText(line2.split(";")[1]);
          input.close();
        }
        catch (Exception e) {
            // TODO: handle exception
        }
    }
user547995
  • 2,036
  • 8
  • 33
  • 62
  • what isn't particulary work? what is the problem? – Vladimir Ivanov Dec 27 '10 at 11:58
  • I'm not sure what you try to achieve. But the file name ("login.skip") sounds, that you'd like to remember the state of your app, so you could do this: http://stackoverflow.com/questions/151777/how-do-i-save-an-android-applications-state – Herr K Dec 27 '10 at 11:59
  • i want to save a file IN the app not on the phone memory...... – user547995 Dec 27 '10 at 12:00

1 Answers1

1

Edit: See Internal Storage

Alternative, Use SharedPreference It'll be Private to you're Application. And cannot be accessed otherwise. (For a non-rooted phone, atleast)

st0le
  • 33,375
  • 8
  • 89
  • 89