Posts

Showing posts from September, 2012

Android - SQLite Database

Image
Android provide SQLite database for an storage option. This post will provide a overview on how to use it.

SQLite Database

It is a private storage space for application. It is persistent, suitable for complex data structure and long term storage. The database will be removed when you uninstall the application.


SQLiteOpenHelper Overview
SQLiteOpenHelper is a helper class that manage SQLite database and version management. In order to use SQLite database, you need to extend this class for database management.
When extending this class, you will need to create a constructor and override 2 methods
Constructor - in the construct, you will need to call the super() method. This method is the primary method that allow you to define the database and database version
onCreate() - This method will be called if the database does not exist. It is a place where you can create your database schema
onUpgrade() - This method will be called if the database version is increased in the code. It is a place…

Android - Storage Options

Android provides many ways for developers to store their application data. Developers should understand their application requirements before selecting the method to store their data.

This post is to provide a high level view on how to select the application storage options

Shared Preference

Shared Preference allow you to store primitive data type as key-value pair. The data is persistent across user session even if your application is killed. Shared Preference data can only be access within the same application. Also, Shared Preference stored the data into memory after first access from the application. So, it is not recommendable for large dataset.

Shared Preference is suitable for


Small and simple storage. Just a key and a small dataset with simple data structureData that requires frequent accessPassing data between Activities
Internal Storage

Internal Storage save your data into application private folder. These saved data cannot be access by other application. When you uninstall yo…