Need help to solve sharedPreference probem

Posted by HFherasen on Stack Overflow See other posts from Stack Overflow or by HFherasen
Published on 2012-11-04T16:40:43Z Indexed on 2012/11/04 17:00 UTC
Read the original article Hit count: 123

Filed under:
|

I am working on this app where I have one EditText field where you can write somthing and then it get saved and added to a list(TextView). I save the content of the EditText in this way :

saved += "*" + editTextFelt.getText().toString() + ". \n";

saved is a String. Everything works fine, I can even reload the app and it's still displayed in the TextView, but if i try to write somthing and save it everything that was there, now dissapear. anyone know why ? It's kind of confusing, and I have to get it to work! Thank's!!

CODE: init Mehtod()

sp = getSharedPreferences(fileName, 0);
betaView = (TextView)findViewById(R.id.betaTextView);

Ive got a button to send the text, and this is like: p

ublic void onClick(View v) {
        switch(v.getId()){
        case R.id.btnSend:
            saved += "*" + editTextFelt.getText().toString() + ". \n";
            SharedPreferences.Editor editor = sp.edit();
            editor.putString("SAVED", saved);
            editor.commit();

            betaView.setText(sp.getString("SAVED", "Empty"));   

© Stack Overflow or respective owner

Related posts about java

Related posts about android