I have done research on database which we can use in android app. I have found multiple databases like Berkeley DB, SQLite, Couchbase and Realm that support data storage in android application. But I have found following two databases which are best for Android application development.
· SQLite database
SQLite is an open source SQL database that stores data to a text file on a device. Android comes in with built in SQLite database implementation.
SQLite supports all the relational database features. In order to access this database, we don't need to establish any kind of connections for it like JDBC, ODBC. We only have to define the SQL statements for creating and updating the database. Afterwards the database is automatically managed by the Android platform.
Access to an SQLite database involves accessing the file system. This can be slow. Therefore, it is recommended to perform database operations asynchronously.
Realm is a mobile database and a replacement for SQLite. Although is an OO database it has some differences with other databases. Realm is not using SQLite as its engine. Instead it has own C++ core and aims to provide a mobile-first alternative to SQLite. The latest version at the moment is 0.90.0.
Advantages of Realm over SQLite:
· Faster than SQLite database (up to 10x speed up over raw SQLite for normal operations)
· Easy to use
· Object conversion handled
· Convenient for creating and storing data on the fly
· Realm has lots of modern features, such as JSON support, a fluent API, data change notifications, and encryption support.
Disadvantage of Realm:
· Can’t access objects across threads
· Still under active development
· Deleting and updating one by one slower in Realm than SQLite.