Question: I have a user login app, which takes email, and password from user. I want to save the email and password in phone cache so user does not have to type again. Is there any way to save data in Android cache.

Answer: 
You can use `SharedPreferences` for that..

```
SharedPreferences wmbPreference1,wmbPreference2;    
SharedPreferences.Editor editor;

//wmbPreference for Shared Prefs that lasts forever
wmbPreference1 = PreferenceManager.getDefaultSharedPreferences(this);  

//installsp for Shared Prefs that lasts only just once each time program is running
wmbPreference2 =getApplicationContext().getSharedPreferences("install_code_prefs",Activity.MODE_PRIVATE);

```

To save values 

```
SharedPreferences.Editor editor = wmbPreference1.edit();
editor.putString("MYKEY", "12345");
editor.commit();

```

You can retrieve the values like

```
String Phonenumber = wmbPreference1.getString("MYKEY", ""); 

```

where **MYKEY** is the keyname by which you can identify the value..
**1.Declare these variables/constants in your class**

```
private SharedPreferences prefs = null;
public static final String MY_PREFERENCE = "my_preference";// preference name
public static final String USER_NAME = "username"; // key for username
public static final String PASSWORD = "passoword";//key for password

```

**2.now save user and password in you method**

```
prefs = getSharedPreferences(MY_PREFERENCE, 0);
SharedPreferences.Editor editor = prefs.edit();
        editor.putString(USER_NAME, username);
        editor.putString(PASSWORD, password);
        editor.commit();

```

Where **username, password** are the strings you got from user input.