How to create a saving xml file with Shared Preference

Basic Tutorials concerning: GUI, Views, Activites, XML, Layouts, Intents, ...

How to create a saving xml file with Shared Preference

Postby Vuvi33 » Thu Nov 18, 2010 3:21 am

I have another question please.

Code: Select all
public class Settings extends Activity implements OnClickListener{
   
   Button b3, b4;

   public static final String PREFS_SETTINGS = "mySharedPreferences";
   
--Ommitted --
         
         @Override
         public void onClick(View v) {      
            
            int mode = Activity.MODE_PRIVATE;
            //SharedPreferences mySharedPreferences = getSharedPreferences(PREFS_SETTINGS,mode);
            
              //SharedPreferences sp = PreferenceManager.getDefaultSharedPreferences(this);
            
            //Intent data = new Intent();
              EditText na1 = (EditText) findViewById(R.id.txt_Person1);
              na1.setText(PREFS_SETTINGS, null);
              EditText na2 = (EditText) findViewById(R.id.txt_Person2);
              na2.setText(PREFS_SETTINGS, null);



            showDialog(0);
            
         }
      });
   
    }
   



When I typed "Tim" in the textbox and select the "Save" button, the text in the textbox is chnaged to "mySharedPreferences". Can I know where my mistake is and how to correct it.

and

May I ask how can I save my data using the codes below.

Code: Select all
            int mode = Activity.MODE_PRIVATE;
            //SharedPreferences mySharedPreferences = getSharedPreferences(PREFS_SETTINGS,mode);
            
              //SharedPreferences sp = PreferenceManager.getDefaultSharedPreferences(this);



I'm creating a xml files after saving. But I don't how to.

Thank you. Help greatly appreciate. :)
Vuvi33
Freshman
Freshman
 
Posts: 3
Joined: Wed Nov 10, 2010 7:47 am

Top

Return to Novice Tutorials

Who is online

Users browsing this forum: Google [Bot] and 5 guests