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: 
I think you need to use `SharedPreference` for that which save your data while your application in your device. After uninstall the app from device the data will be remove.

1) Save Data to `SharedPreference` :

```
SharedPreferences prefs = getSharedPreferences("UserData", MODE_PRIVATE);
SharedPreferences.Editor editor = prefs.edit();
editor.putString("username", username);
editor.putString("password", password);
editor.commit();

```

2) Retrieve data from `SharedPreference`:

```
SharedPreference prefs = getSharedPreferences("UserData", MODE_PRIVATE);
String username = prefs.getString("username","");
String pwd = prefs.getString("password","");

```
**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.