Featured Posts

<< >>

MSQLite library

MSQLite is my first library for Android. It’s a wrapper for Android’s SQLiteOpenHelper that extends it by adding methods for easier data manipulation. Source code is available on GitHub: https://github.com/mick88/MSQLite The aim of this project is to make it easier for beginner developers on android to use database, but at the same time give them direct control

Convoy Trucking Android app

ic_launcher

Convoy Trucking android app a companion app meant for Convoy Trucking players to view website content without having to switch to web browser. It is designed for both phones and tablets, and looks beautiful on both. It fetches data as a json feed from Convoy Trucking API and uses Universal Image Loader library to download and cache

DIT Timetables

ic_launcher

An android app for DIT students to view their timetables. It downloads timetable data from web timetables and saves a local copy on user’s device. It lets user filter lectures and labs by group. DIT Timetable in Google Play Store

Convoy Trucking

Convoy Trucking

Project website: www.convoytrucking.net. Community forums: www.forum.convoytrucking.net   This gamemode is my first and biggest project in Pawn. I started working on it in January 2010 and in two weeks created server called Convoy Trucking. To this day I continue working on it, and the community of players keeps growing. Some of the features included in

Update to MSQLite library

Recently MSQlite library saw few new updates:

  1. Tracking classes
    The library allows adding classes to ‘tracked classes’ by calling trackClasses() or trackClass() this adds class(es) to a collection of tables that will create automatically in onCreate() and upgrade in onUpgrade(). These method must be called before MSQLiteOpenHelper.onCreate(), or you can use one of the new constructors to pass an array of classes directly.
  2. Serialization of non primitive fields
    All class members will be added to database table as columns by default. If member type is not a primitive or integer, the library will attempt to serialize it, or throw an exception if type does not implement Serializable.
  3. Upgrading tables
    When new fields are added to class, and database version number is increased, the SQLite framework will call onUpgrade() which will upgrade table columns to match the classes. This is limited to adding new columns since SQLite’s ALTER TABLE command is limited to ADD COLUMN.

MSQLite library

MSQLite is my first library for Android. It’s a wrapper for Android’s SQLiteOpenHelper that extends it by adding methods for easier data manipulation.

Source code is available on GitHub: https://github.com/mick88/MSQLite

The aim of this project is to make it easier for beginner developers on android to use database, but at the same time give them direct control on how data is stored. By default table and column take over names from Class/field, but table and field names can be customized by using @TableName() or @ColumnName() annotation. This is very useful if you are upgrading your current database solution to MSQLite, and your database fields differ from class field names. Another useful feature is excluding select fields from database by adding transient keyword to them.

It uses generics and reflection features of java languages to interpret classes as database tables. This way users can easily insert data to database without worrying about SQL syntax. It also uses annotations for adding metadata to database tables/columns, like Primary Keys, names or data types.

The main class MSQLiteOpenHelper extends SQLiteOpenHelper, so upgrading your database helper with new methods is as easy as changing which class you extend. This gives you access to a number of useful methods

Currently supported field types are:

  • Primitives: int, double, float, long, short, char, byte
  • Wrappers for primitives: Integer, Double, Float etc…
  • String
  • Serializable

 Examples:

Database helper can now look as clean as this:

 

The following is the Note class from the above example:

This is an example of plain Java class that can be converted into database table using createTable() method. There is no need to extend any class or implement any interface. The @PrimaryKey annotation points to field that will be used as a primary key in the table. It is not required, and since SQLite supports multiple PrimaryKeys, multiple fieds can be defined as such. Similarily @NotNull specifies that field may not be null.

The createTable() method effectively creates and executes the following SQL statement:

 

Inserting instance of Note into database can be easily done by calling static insert() method:

or using the helper insert() method on an instance of DatabaseHelper, which gets database instance for you, and closes it afterwards:

TIP: If your PrimaryKey is an integer and is null, after insertion it will take value of row id after insertion.

Inserting a batch of objects is just as simple, you just have to specify Type of the objects in the List:

Sure enough, selecting data is just as easy. The selectAll() method returns a List of all objects of specified type:

If you need more control over which data you need, you can use the main select() method, which wraps SQLiteDatabase.select() method:

Obviously there are also methods for deleting, updating and even replacing items in database:

 Downsides?

  • Currently MSQLite doesn’t support relational databases, so non-supported fields must be declared as transient or implement Serializable.
  • Performance of this solution hasn’t been measured, but it’s expected to execute slower than code tailored for your specific needs.

Convoy Trucking Android app

ic_launcher

Convoy Trucking android app a companion app meant for Convoy Trucking players to view website content without having to switch to web browser. It is designed for both phones and tablets, and looks beautiful on both.

It fetches data as a json feed from Convoy Trucking API and uses Universal Image Loader library to download and cache images.

The app can be downloaded from Google Play: Convoy Trucking.
The source code is available on GitHub.

2013-07-28 13.14.39_framed 2013-07-29 17.54.22_framed 2013-07-28 13.13.58_framed

Dubline Storymap

ic_launcher

Dubline Storymap is a customized version of Storymap with its own stories talking about Dublin city’s attractions. Just like the original Storymap, Dubline offers its users rambles across town as well as creating custom ramble by user which highlights nearest stories on the map.

Dubline can be downloaded for free from Google Play: Dubline Storymap

2013-07-24 19.24.42_framed2013-07-24 19.24.21_framede8b15271-3758-4bcd-afe8-b6dc5ada378b

MySQL Backup Engine

Finally, I got around to updating my database backup utility! I started by creating a MySQL connection library and a “Backup Engine” library, which I hooked up to a test console app. This approach will allow me to have two different applications that use the same back end. One application will be a windows client and the there will be a command line utility as well.

The original version was created over a year ago and hasn’t been worked on until now.

The new project consists of:

  • Database connection library
  • Database Backup engine
  • Commandline app
  • Windows forms app

It saves backup into .sql files of predefined size. I created a DynamicFile class which saves text data into multiple files and allows the programmer to get the list of filenames afterwards:

Actually, I extended this class into DynamicSqlFile and created some methods useful for writing SQL files:

It has a handful of useful methods, like WriteComment(), which automatically appends “– ” before the text and ends it with a NewLine character. It also returns and instance of itself, making this possible:

Which makes for very compact and readable code. It ends up looking like this in the SQL file:

Commandline interface:

cmd_backup

Work in progress

Work in progress