This topic applies to Java version only
Android is a new complete, open and free mobile platform. Android offers developers a java based software developer kit with lots of helpful APIs, including geolocational services. Of course, there is a database support as well: Android has a built-in support for SQLite database. The basic API is similar to standard JDBC API, however some effort was added to create some convenience methods:
public int delete(String table, String whereClause, String[] whereArgs)
public long insert(String table, String nullColumnHack, ContentValues values)
public Cursor query(boolean distinct, String table, String[] columns, String selection, String[] selectionArgs, String groupBy, String having, String orderBy)
public long replace(String table, String nullColumnHack, ContentValues initialValues)
This may look better than SQL, but if you look closer you can see that all column names and selection criteria are specified as strings, so we still stay with a problem of run-time checking instead of compile-time.
Luckily even for this very early Android release we already have an alternative - db4o. Yes, db4o runs on Android out of the box and produces very competitive results as well. The following application compares db4o and SQLite usage for basic operations. It also contains some operation duration calculations that can be used to compare db4o vs SQLite performance. Please, note that these results are for an overview purpose only and there are many configuration settings that can change performance of both databases. Also running in emulator does not guarantee the same results as in real device. You can download the whole application code here.
The steps to install db4o on Android are quite simple thanks to Eclipse.
private String db4oDBFullPath(Context ctx) {
return ctx.getDataDir() + "/" + "dbfile.yap";
}
Otherwise Android security will prevent the creation of the database file.