Question: I am stuck here:

System.out.println("Enter the number to be added to these factorial numbers:");
 System.out.println("1!/1 + 2!/2 + 3!/3 + "); //factorial ie. 5!/5 = 4 \* 3 \* 2 \* 1 
 n = scan.nextInt();

```
     while (!exit)
    {

        if (n <= 2) 
        {
            sum = 1;
            exit = true;
        }
        sum = sum + i - 1;

        i = i - 1;
        if (i == 2)
        {
            exit = true;
        }
    }

     //m2 = 1 * 1 + (2 * 2) + (2 * 1) + (3 * 3) + (3 * 2) + (3 * 1) + (n * n -1);  
     //System.out.println(m2);

```

Answer: 
For a single value such as balance or username you should definitely use [SharedPrefereneces](http://developer.android.com/intl/ru/reference/android/content/SharedPreferences.html) and [OnSharedPreferenceChangeListener](http://developer.android.com/intl/ru/reference/android/content/SharedPreferences.OnSharedPreferenceChangeListener.html).

For structured data such as balance operations you should definitely use a database:

* **SQLite**
* **Realm** (noSQL)
* **StorIO** (SQLite wrapper)

or some **ORM**.
There is 3 way to store you login details .

1. Using [Shared Preference](http://developer.android.com/reference/android/content/SharedPreferences.html)
2. [Store Data in a File](http://developer.android.com/training/basics/data-storage/files.html)
3. Using [Sqlite](http://developer.android.com/training/basics/data-storage/databases.html).

[**This tutorial**](http://www.skill-guru.com/blog/2011/01/17/data-storage-mechanisms-in-android/) will give you the ideas for storing login details.