Need help to solve sharedPreference probem
- by HFherasen
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"));