Friday, February 10, 2012

SQLite

The Android framework uses a concept called Content Provider to allow applications to share and use data across the platform. Typically, this Content Provider is backed by a SQLite Database where the data is actually stored.

A few days ago I saw a presentation of SQLite, actually a Google TechTalk made by it's developer, Richard Hipp, on May 31, 2006. I really liked it, so I wrote down some important features of SQLite:

  • it's very small and compact (the code footprint has less than 250KB)
  • serverless (writes directly to the disk drive)
  • the database is contained in a single disk file
  • zero-configuration (there is no need of setup or administration)
  • you can read/write the database file with fopen(), fread(), fwrite()
  • transactions satisfy ACID (atomicity, consistency, isolation, durability)

There are also some unusual features of SQLite:
  • tends to ignore the data types (you can type whatever you want in every column - inspired by scripting languages)
  • type affinity
    • Example: If the type of a column is integer and you want to put there a string, if the string looks like an integer, it will be automatically converted, and if not, it will be stored as a string.
  • ability to talk to multiple databases simultaneously (you can join 2 tables from 2 databases)

I managed to create a simple application which adds a person's first name and last name in a database using Content Provider. The user can see the data in the database on the screen, delete or add items. It looked pretty simple at first, but it took a whole day to actually realize how everything worked. 

Next step for me concerning the development of the application is to try to store some pictures in the database (binary data) and to use the CRUD functions that are implemented by parallel thesis. Also I must describe the requirements for my project.

No comments:

Post a Comment