Android Sqlite Database and Its File System Discussed In Detail

admin | June 9th, 2015 | General

Last time we discuss the Sqlite Interface with OS and browsers so know we thought to dive deep in to Sqlite OS interface so this time we have chosen Sqlite Android Interface to be a topic of discussion. Android stores its data using Sqlite database engine which is an independent transactional engine for accessing and management of database. It requires no dedicated server process. Most application and platforms beyond the mobile operating system Android use Sqlite. Unlike the desktop based databases, Sqlite cuts short the features that are not necessarily important and as a result achieves minute footprint.

Database systems use the static typing while Sqlite prefers manifest typing instead. It pushes the data type information accountability to high-end computing languages like; Java. This maps the structure of database to high-end types.

Reasons Why Android Uses Sqlite

Most importantly, the key feature that Sqlite is chosen for is its reliability. A majority of the project codes are devoted for library testing. And the library is structured in a way that it can handle system failures of different types such as; disk errors, low storage memory, or power failure.

It is ensured that a database is never left in an unrecoverable state because all the essential data for mobile phones are stored within a database file. Therefore, using Sqlite is a fortunate step as it makes the mobile database insusceptible to corruption that could easily take place. If not, every time that the battery discharges, a database corruption would take place.

Other Grounds On Which Android Uses Sqlite

  1. No installation, no setup. Moreover, Sqlite requires no administration as it works independent of a platform or administrator to manage or process it.
  2. Cross platform. Also, the database is created in a stable format and with backward compatibility which makes it usable on an older version too.
  3. A dedicated database file is created. Sqlite when used on a platform or for an application creates a single database for its entire entry and information storage.
  4. Manifest typing vs. static typing. Unlike SQL database, Sqlite datatype is not a property of the column storing the value but of value itself. Thus, any value of whichever datatype can be stored in a random column irrespective of the column’s declared type.

Delving Into the Sqlite Database for Android and Its Structure

Android and other mobile operating systems come with Sqlite integrated in their environment and thus are used by applications designed for it. The primary data repository for android is Sqlite and all of its databases are located on the respective device location:android-sqlite-interface-1

The Database files for each application are located within a subfolder in its section of the file system. An application DB is kept private to the application itself and is protected by File System permissions of Linux. However, the database is not in an encrypted state and can be opened and viewed in the right environment. Basically the data base file for each application is stored in the mentioned location (differs on the basis of Android version) and is named after the application name itself.

android-sqlite-interface-2

The database can be viewed using the Dalvik Debug Monitor Service of an emulator. However, if a physical device is being used then browsing may not be possible until or unless the device is routed.

NOTE: DDMS () comes as a part of the software development kit, Android SDK which enables to design and develop apps for the OS. The kit also includes emulator, source codes with sample projects, development utilities, and libraries for app building along with DDMS.

Understanding the Database Structure

A common database is assigned for the entire application data storage. This DB file consists of tables with corresponding information and each table has multiple pages and in it are cells denoting each entry. These pages are mostly structured in B-tree format where one page is a compilation of a particular number of bytes which has a size with a power of 2. All pages in a database are of the same size and are structured with numbering starting with 1.

For instance, here is the view of database file created by a dictionary application on Android.

android-sqlite-interface-3

Following is a view at the ‘word_types’ table in the dictionary application database .

android-sqlite-interface-4

Variety And Evolution in Android File System

EXT or the Extended File System is a genuine, Linux developed file system. Though Linux supports a number of file systems, EXT remains its default. Post the release of original EXT version, three more version releases took place; EXT2, 3 and 4 respectively.

Coming over to the point, earlier Android devices did not have EXT though it had been a built-in in most of the desktop, laptops, and Linux distribution server. But very soon Android Developers made a move of the Mobile OS based device file systems from YAFFS to EXT.

The move was initiated owing to a number of reasons, which included:

  1. Android devices were now moving from raw NAND flash into a regular block device.
  2. EXT4 being a standard file system of Linux supported full UNIX based permissions and semantics.
  3. Also, it is relatively more stable and high on performance.
  4. Dual core processors were forthcoming on which YAF File Systems would encounter constrictions due to being single threaded.

The types of file systems Android has had over the time are: YAFFS, YAFFS2, ext2, 3, 4, and vfat. YAFFS was a robust file system supporting NOR / NAND flash chips. Also, were designed to particularly be used in embedded devices. While EXT and its versions were a Linux based file system that introduced lots of improvements like; ext2 was developed to resolve ext issues, ext3 further added the facility for journaling, and the fourth edition (currently in use) made the provision for large FS and file size support. Meanwhile vfat is a FAT32 file system by Microsoft dedicated for SD cards.

Conclusion: The above information shows that, though a common database is accessible using commercial tools, main application database for any Android device can only be acquired with the right environment, tools/platform. The limitation is basically a plus point about Sqlite database as though they aren’t easily corruptible but are also not provided access of, to end users. You can also explore the Android Sqlite by using a freeware utility such as Sqlite Browser.

Disclaimer : – © 2020 Sqlite Viewer is an independent provider of Sqlite products & services. Sqlite Viewer is not in affiliation with any of the third–party organizations unless it is expressed explicitly. Read More...