Sunday 24 June 2012

Android SQLite Database Design Pattern - Extensible, Blocking and Simple

This post is in response to my need to have an Android Database that will:

A) Never ever get into an illegal state, i.e. errors occur if you create/write/read tables at the same time.
B) Split up management of Database tables by creating classes for each one, but still using one single Database.
C) Reuse common Database functionality by creating helper methods.
D) Works at least in Android 2.1+.

Monday 16 January 2012

Android Intents - Passing Serializable Custom Objects to an Activity

The passing of custom objects to an Activity using Intents can seem very confusing - honestly I never quite worked out how to use Parcelable. It seemed like a lot of code for passing a custom object to one of my activities. The method of passing objects I settled for was one that required the least amount of code and did the job.

Thursday 12 January 2012

Android Custom Logging - Enable/Disable Logs

Part of the Android 'Preparing for Release' onto the Android Market is to remove all Log messages and have the android:debuggable="false" in the manifest file. This is outlined here in the section called 'Turn off logging and debugging'.

Removing all logs can be difficult, however you might still decide, that's okay I will comment all my logs out! This would not be a bad idea but its not the most efficient by far, an alternative is to add 'if' statements for every Log in your app that points to a global boolean flag...however that is also not easy with lots of Log calls.

Sunday 23 October 2011

Java Message Box (Alert Popup)

A simple alternative to printing out messages in the console, this code will popup a message box in Java similar to that of Javascript alert("hello").

The code can be modified to include several types of message box types such as an error icon or different button options. Have a look JOptionPane in the JavaDoc's for more information on these.

Monday 10 October 2011

Java Custom Component - Colored Progress Bar

After getting slightly bored of the standard Java components available to me I decided to spice things up a little. I wanted to be able to have a clean, colourful and customizable progress bar. I also wanted the progress bar to be able to change colour at certain values, such as when it reaches a low percent it will go red.

Essentially I extend JComponent and use paintComponent method which is called automatically by Java to draw the progress bar.