All Projects → mrafayaleem → gdx-sqlite

mrafayaleem / gdx-sqlite

Licence: other
A cross-platform extension for database handling in Libgdx

Programming Languages

java
68154 projects - #9 most used programming language

Projects that are alternatives of or similar to gdx-sqlite

Gaiasky
Mirror of Gaia Sky repository hosted on Gitlab: https://gitlab.com/langurmonkey/gaiasky
Stars: ✭ 162 (+165.57%)
Mutual labels:  libgdx
EasyStage
A stage profile tool for libgdx
Stars: ✭ 17 (-72.13%)
Mutual labels:  libgdx
kickoff
Open Kick-Off is a fun rewriting attempt of the cult football game Kick Off 2 designed by Dino Dini and released in 1990 by Anco for the Atari ST and the Commodore Amiga. It is written in Java with the help of libGDX.
Stars: ✭ 32 (-47.54%)
Mutual labels:  libgdx
Mundus
A 3D world/level editor built with Java, Kotlin & libGDX.
Stars: ✭ 164 (+168.85%)
Mutual labels:  libgdx
Gdx Rpg
java & libgdx制作的RPG游戏! an RPG by java and LibGDX
Stars: ✭ 239 (+291.8%)
Mutual labels:  libgdx
libgdx-transitions
libgdx screen transitions/fading
Stars: ✭ 43 (-29.51%)
Mutual labels:  libgdx
Gdx Liftoff
A modern setup tool for libGDX Gradle projects
Stars: ✭ 148 (+142.62%)
Mutual labels:  libgdx
GDX-lazy-font
auto self-generate BitmapFont for libgdx 1.5.0 +
Stars: ✭ 26 (-57.38%)
Mutual labels:  libgdx
Martianrun
An Open-Source Running Game with libGDX
Stars: ✭ 242 (+296.72%)
Mutual labels:  libgdx
tripeaks-gdx
A simple tri peaks solitaire game using libGDX.
Stars: ✭ 45 (-26.23%)
Mutual labels:  libgdx
Unciv
Open-source Android/Desktop remake of Civ V
Stars: ✭ 2,744 (+4398.36%)
Mutual labels:  libgdx
Destinationsol
Official continuation of Destination Sol, the great fun little arcade space shooter from http://sourceforge.net/projects/destinationsol/ Modules live at https://github.com/DestinationSol/
Stars: ✭ 214 (+250.82%)
Mutual labels:  libgdx
ForgE
Simple clone of RPG maker using LibGdx
Stars: ✭ 17 (-72.13%)
Mutual labels:  libgdx
Klooni1010
libGDX game based on the original 1010!
Stars: ✭ 163 (+167.21%)
Mutual labels:  libgdx
pixelwheels
A top-down retro racing game for PC (Linux, macOS, Windows) and Android.
Stars: ✭ 315 (+416.39%)
Mutual labels:  libgdx
Gdx Lml
LibGDX utility libraries.
Stars: ✭ 152 (+149.18%)
Mutual labels:  libgdx
DoubleHelix
A live wallpaper and daydream for Android featuring stylized glassy-looking DNA structures
Stars: ✭ 86 (+40.98%)
Mutual labels:  libgdx
bialjam17
💫 The game that won the BialJam'17 event
Stars: ✭ 55 (-9.84%)
Mutual labels:  libgdx
gdx-gameanalytics
Gameanalytics.com client implementation for libGDX
Stars: ✭ 28 (-54.1%)
Mutual labels:  libgdx
Koru
A 2D multiplayer sandbox game.
Stars: ✭ 78 (+27.87%)
Mutual labels:  libgdx

gdx-sqlite

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: http://www.vogella.com/articles/AndroidSQLite/article.html

Latest build of this extension can be downloaded from: http://bit.ly/gdx-sqlite

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
<forceLinkClasses>
	<pattern>com.badlogic.gdx.sqlite.robovm.RobovmDatabaseManager</pattern>
	<pattern>SQLite.**</pattern>

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 "
			+ TABLE_COMMENTS + "(" + COLUMN_ID
			+ " integer primary key autoincrement, " + COLUMN_COMMENT
			+ " text not null);";

	public DatabaseTest() {
		Gdx.app.log("DatabaseTest", "creation started");
		dbHandler = DatabaseFactory.getNewDatabase(DATABASE_NAME,
				DATABASE_VERSION, DATABASE_CREATE, null);

		dbHandler.setupDatabase();
		try {
			dbHandler.openOrCreateDatabase();
			dbHandler.execSQL(DATABASE_CREATE);
		} catch (SQLiteGdxException e) {
			e.printStackTrace();
		}

		Gdx.app.log("DatabaseTest", "created successfully");

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

		DatabaseCursor cursor = null;

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

		try {
			dbHandler.closeDatabase();
		} catch (SQLiteGdxException e) {
			e.printStackTrace();
		}
		dbHandler = null;
		Gdx.app.log("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.

License:

This extension follows the Apache License version 2.0 (http://www.apache.org/licenses/LICENSE-2.0.html)

See License FAQ http://www.apache.org/foundation/licence-FAQ.html for more details.

Reporting Bugs:

Please email any bugs or feature requests at: mrafayaleem at gmail.com

Author:

Mohammad Rafay Aleem

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].