Switch branches/tags
Nothing to show
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.


Note: This project is no more actively maintained. Please check out the various forks here to follow up with active developments around this repository.

gdx-sqlite is a cross-platform Libgdx extension for SQLite database handling. The extension abstracts databse handling to provide a unified method to handle database transacitons across multiple platforms while also adding SQLite support for desktop version of Libgdx application.

Currently supported platforms:

A small portion of code has been adapted from the tutorial located at:

Latest build of this extension can be downloaded from:

Extension setup in a Libgdx application:

Note: This setup assumes that you have properly setup your project as follows (or similar to the following):

  • App
  • AppDesktop
  • AppAndroid

For App project:

  • Copy gdx-sqlite.jar into your App project libs folder
  • In the Libraries tab of your Java Build Path, add the gdx-sqlite.jar

For AppDesktop project:

  • Copy gdx-sqlite-desktop.jar and sqlite-jdbc-3.7.2.jar into your AppDesktop project libs folder
  • In the Libraries tab of your Java Build Path, add the gdx-sqlite-desktop.jar and sqlite-jdbc-3.7.2.jar

For AppAndroid project:

  • Copy gdx-sqlite-android.jar into your AppAndroid project libs folder
  • In the Libraries tab of your Java Build Path, add the gdx-sqlite-android.jar and gdx-sqlite.jar
  • In the Order and Export tab of your Java Build Path, make sure that gdx-sqlite-android.jar and gdx-sqlite.jar are checked

For AppRoboVM project:

  • Add following lines to robovm.xml

Example Code:

package com.mrafayaleem.gdxsqlitetest;

import com.badlogic.gdx.Gdx;
import com.badlogic.gdx.sql.Database;
import com.badlogic.gdx.sql.DatabaseCursor;
import com.badlogic.gdx.sql.DatabaseFactory;
import com.badlogic.gdx.sql.SQLiteGdxException;

public class DatabaseTest {

	Database dbHandler;

	public static final String TABLE_COMMENTS = "comments";
	public static final String COLUMN_ID = "_id";
	public static final String COLUMN_COMMENT = "comment";

	private static final String DATABASE_NAME = "comments.db";
	private static final int DATABASE_VERSION = 1;

	// Database creation sql statement
	private static final String DATABASE_CREATE = "create table if not exists "
			+ " integer primary key autoincrement, " + COLUMN_COMMENT
			+ " text not null);";

	public DatabaseTest() {"DatabaseTest", "creation started");
		dbHandler = DatabaseFactory.getNewDatabase(DATABASE_NAME,

		try {
		} catch (SQLiteGdxException e) {
		}"DatabaseTest", "created successfully");

		try {
					.execSQL("INSERT INTO comments ('comment') VALUES ('This is a test comment')");
		} catch (SQLiteGdxException e) {

		DatabaseCursor cursor = null;

		try {
			cursor = dbHandler.rawQuery("SELECT * FROM comments");
		} catch (SQLiteGdxException e) {
		while ( {"FromDb", String.valueOf(cursor.getString(1)));

		try {
		} catch (SQLiteGdxException e) {
		dbHandler = null;"DatabaseTest", "dispose");

Compiling the Code:

The repository contains all the necessary libraries and files to generate jar files. Three test projects are also added which depend on the respective gdx-sqlite projects to run. To generate jar files from the source code, clone the repository and execute ant clean build command from the root directory. This will generate jars in their respective folders (in jar directory of each gdx-sqlite project). Note that the gdx-sqlite projects are independent of the test projects.


This extension follows the Apache License version 2.0 (

See License FAQ for more details.

Reporting Bugs:

Please email any bugs or feature requests at: mrafayaleem at


Mohammad Rafay Aleem