Using Dialogs & Saving Data

Return to Android Development Syllabus
Dialogs

Dialogs (sometimes called modal windows) are used when there is immediate interaction needed with the user. The dialogs stop the user’s interaction from any other UI component till any action is taken on it. Most of the times they are used to alert user of something/get confirmation or used to get input without which the app cannot proceed further. An example would be a “Discard draft?” popup message.

Android Modal Window example
Saving data

For a good user experience we need to save regularly needed user data in our app. For e.g. Facebook app saves your login info so that you don’t have to login every time when you open their app.

Saving Data in Shared Preferences

Shared preferences is a provision given by the android SDK to store key value pairs in your app. As the name suggests, it is mainly used for storing small stuff like user preferences and settings.

Saving Data in Files

Saving data in files is another way to save user data for your app. This is mostly used when you have to store considerable amount of textual data. E.g. a note taking app

Saving Data in SQLite Databases

For saving relational/complex data in your apps, you can use Sqlite database. Sqlite is a tiny database that comes pre-packaged with the android OS. E.g. a contacts app that needs to save and display different contact details of multiple users.

4 Curated Resources

Android - Alert Dialogue

free, Tutorial

Shows you how to create and display Dialogs in your app

Helps you learn how to work with shared preferences with a sample application.

Saving Files

free, Documentation

Official Android documentation on the basics of storing data using files.

Saving Data in SQL Databases

free, Documentation

Official Android documentation on how to setup, configure and work with a SQLite database in your app.