Footy Links Alpha released

The very first version of Footy Links is now available for download from the Android Market.
You can get the app by opening the following website on your android device and press the ‘Install’ button:
Footy Links on the Android Market

What is Footy Links?

Footy links is a game designed to test your football knowledge by guessing clubs connecting premiership football players. Make your guess by clicking on the blue text then selecting the club badge matching the answer.

There is a basic scoring system following these rules:

  • +1 point for every correct guess of a ‘top six’ club
  • +2 points for a correct guess of any other club
  • -1 point each time you skip to another question without answering the previous one

Can I play it?

If you have an Android based mobile device I hope so, it should work on any device with Android OS version 2.2 or above. If you have any problems running the game feel free to contact me here on my blog or through twitter

Is that it?

As you may be able to tell from the title, in the spirit of agile development (or maybe just because I’m lazy), this is an early version with the absolute minimum set of features. I really wanted to just get a version out there in the wild to see if it will work on anyone’s phone other than my own!

But do not fear, more versions are planned with lots of exciting extra features, possibly including:

  • Harder difficulty levels – more links to guess between each of the players
  • More advanced scoring system
  • Multi-player games
  • Online high score board
  • Inclusion of all English leagues
  • Inclusion of European league clubs

If you have any suggestions about Footy Links then please feel free to get in contact with me here on my blog or through twitter

The Techy Bit

If you’re interested in how the app works behind the scenes, the source is freely available for viewing on my github account here:
Footy Links on github

The source consists of two applications

  • A .NET application written to import the football club and player data into a Sqlite database
  • An android application for the game itself

Developing Android Apps: Connect to an existing SQLite database

This post was drafted some time ago, so some of the details are lost in the mists of time. But I’ll provide links to the source so anyone interested in doing something similar can start from there.

The android app I’m developing needs to be able to connect to an existing SQLite database, there are not many examples of how to achieve this in the Android tutorials, however I was able to find some guidance in a post from another Android developer on the reigndesign blog

The key is that the database needs to be copied internally to the system directory on the device running the application before it can be accessed. This doesn’t seem particularly efficient but I’m sure Android had their reasons! My modified version of the code to do this is available from my github repository here:

FootyLinksSQLLiteHelper.java

I’ve also encountered a couple of other snags since then while working with the SQLite database.

No password support

Passwords do not appear to be supported at all for the Android applications. I’d automatically added password protection to the database when creating it and it took me a while to figure out why eclipse was refusing to read it!

Manually delete after schema changes

I’ve added some additional fields to the database over time. However initially they were not being copied into the version of the database in my device emulator. I found it was necessary to browse the emulator files themselves, using the DDMS perspective in Eclipse, and delete the old database file directly in the emulator file system.

Nhibernate generator class for SQLite databases

I’ve been developing a mobile app for Android which needs to query data in an SQLite database. So the first task I needed to get done was to import data into the SQLite database. As I’m more used to writing .NET applications which use the NHibernate ORM I decided to write an import program on this technology stack.

For my first attempt at the import program I just wanted to focus on the import logic, so choose to use a ‘known working’ NHibernate configuration with a MS SQL 2005 database. While this worked fine for me it did mean that I had to manually copy all of the data from the MS SQL database into the SQLite database before it could be used in the Android app. This was quite laborious so when I needed to modify the importer at a later date I decided to change the NHibernate configuration to point directly to the SQLite database instead. This was the updated config file used:

<hibernate-configuration  xmlns="urn:nhibernate-configuration-2.2" >
    <session-factory>
        <property name="connection.provider">NHibernate.Connection.DriverConnectionProvider</property>
        <property name="connection.driver_class">NHibernate.Driver.SQLiteDriver</property>
        <property name="connection.connection_string_name">FootyLinks</property>
        <property name="dialect">NHibernate.Dialect.SQLiteDialect</property>
        <property name="query.substitutions">true=1;false=0</property>
    </session-factory>
</hibernate-configuration>

And this is an example of the connection string format:

<configuration>
    <connectionStrings>
        <add name="FootyLinks" connectionString="Data Source=C:\path_to_the_SQLite_database_file;Version=3"/>
    </connectionStrings>
</configuration>

This configuration worked OK and the import program could connect to the SQLite database, however I hit a problem when trying to save new records to the database. This was the inner exception reported by NHibernate:

Abort due to constraint violation Club.Id may not be NULL

The problem was that the import program was using the default generator class of identity for in the NHibernate entity mappings. So NHibernate was expecting the database to generate the identity keys for the new records being saved to the database, however SQLite does not appear to support this. After some reading up on the options available for the NHibernate generator setting I decided to try the native setting. As this should select the implementation supported by the database. However this didn’t work either, I think because, of all the options native can select, none are actually supported by SQLite. So my next preferred selection was to use increment, this setting comes with a disclaimer that it should not be used in a cluster, which is absolutely fine as its very unlikely that I will ever be deploy the importer to a load balanced environment.

The increment setting worked fine with the SQLite database and should streamline my workflow nicely for updating the app data .

FootyLinks roadmap

  1. Make lowest difficulty level easier (squad numbers?, exclude older players?)
  2. Correct answer page
  3. Display score in game
  4. Increment score on correct answer
  5. Fix occasional crashing on view changes (db init to game startup event?)
  6. Only allow user to select roles available at their level
  7. Release one
  8. Level up on score thresholds
  9. Change game rules depending on difficulty level
  10. Post scores to twitter
  11. Update data with latest transfers
  12. Release two