Using Realm databases in Android apps: A beginner’s tutorial

Android realm database tutorial icon

What is Realm?

Think of a Realm as a database.

A Realm is similar to a database and can contain different kinds of objects. You can use a Realm in your app instead of an SQL database.

The Realm is saved in a file on your device and can be backed up.

You can also create a Realm in memory which is destroyed when you close the realm.

Realm works seamlessly with Android and is very easy to set up and use.

There are a number of options for saving data in Android applications. This tutorial bundle covers them all. From shared preferences to a SQLite database and Network storage.

Activities book cover

The tutorials have line-by-line commentary and cover each of the main data storage topics in detail. These are:

  • Shared Preferences tutorial – which enables you to save primitive data in key/value pairs so that they persist both across activities and within activities
  • Internal Storage Tutorial – enables you to save data in the device's internal memory. A second tutorial demonstrates how to save data in the internal cache
  • External Storage – this enables you to save data in the external storage area of the device, such as on a SD card. There are three tutorials here, covering saving data in the private and public areas of the external storage device as well as the external cache.
  • SQLite Database Tutorial – the SQLite database enables you to save complex data in a private database which can also be shared between applications
  • Network Connection Tutorial – enables you to store data on the web which you can then access from any device with an internet connection

Mastering these tutorials will give you the confidence to use any of these options to store data in your application.

This ebook assumes that you have at least completed the “Hello World” tutorial that can be found on the official Android website. The tutorials were created using Eclipse (Helios) and targets Android 2.2 API level 8.

Available at

All the tutorial files are available for download at

You might also be interested in these titles, all available on

  • Android for beginners: Building a Fuel Consumption Calculator with line by line commentary
  • Android for beginners tutorial. Building your own World Flags Application