Monday, June 27, 2011

Store image / audio / video in Database using SQLite

Its is quite easy to store information like TEXT, INTEGER etc into the Database using SQLite. How many people know that we can store large images / audio / video in Database ?

I dint know it until I wanted to do it. And here come the solution. We can convert the images / audio / video into binary data and then store it in BLOB format. And, BLOB refers to a Large Binary Object.

Refer the code, how the bitmap image can be converted into binary data and reverted back to bitmap.

Wednesday, June 22, 2011

Time Zone conversion

Many times I encoutered this doubt, how to handle the time zone difference in our applications. What if the user changes to a different time zone, while our application is time-zone dependent.

Here is the simple understanding with an example. Implementation of an application which store the previously logged in time. Say, now the time is IST 04:00 PM (GMT +5.30). The application will store the current time in the preferences and inform the user about the last logged in time, irrespective of the time-zone.

Step 1: Store the current time always in GMT format. When the current time is stored in specific time zone format, then when the time zone changes, we would not be able to retrieve the appropriate time.
Step 2: Convert them to GMT time to locale time whenever required.
Step 3: Ensure to use proper FORMAT across all the locations in the applications


Refer the following code snippet to understand the conversion process.