Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 9189247
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 17, 20262026-06-17T20:11:56+00:00 2026-06-17T20:11:56+00:00

I am in the process of developing a game with multiple worlds and levels

  • 0

I am in the process of developing a game with multiple worlds and levels (each having their individual data) which I want to store in SQLite database on Android. I have implemented SQLite in some very basic apps but so far I am unable to get it working along side the libgdx framework.

What I have actually done is that I am maintaining an Assets class that has some static members for use in classes elsewhere. I have a private static nested class by the name of SQLHelper that maintains the query strings and some private methods to handle the SQLite database when the app runs on an Android phone/Emulator.

Here is a glimpse of the code:

public class Assets {
//A lot of code (unrelated to SQLHelper class) and to be used in classes elsewhere

SQLiteDatabase database;

//SQLHelper class
private static class SQLHelper {

    private static String createTableSettings = "CREATE TABLE IF NOT EXISTS settings(settingID INTEGER PRIMARY KEY, settingName VARCHAR(15) NOT NULL, settingParamOne INTEGER NULL, settingParamTwo INTEGER NULL, settingParamThree INTEGER NULL);";
    private static String createTableWorldData = "CREATE TABLE IF NOT EXISTS worldData(worldID INTEGER PRIMARY KEY, worldScore INTEGER DEFAULT 0, worldStars INTEGER DEFAULT 0);";
    private static String createTableLevelData = "CREATE TABLE IF NOT EXISTS levelData(levelID INTEGER PRIMARY KEY, levelStars INTEGER DEFAULT 0, worldID INTEGER NOT NULL, FOREIGN KEY(worldID) REFERENCES worldData(worldID));";

    @SuppressWarnings("static-access")
    private static void openDatabase() {
        try {
            database.openDatabase("gameName", null, database.CREATE_IF_NECESSARY);
        } catch (Exception e) {
            Gdx.app.log("Exception in opening databases", "This should not happen on an Android Device (This is fine on java.)");
            e.printStackTrace();
        }
    }

    private static void createTables() {

        try {
            database.execSQL("PRAGMA foreign_keys=ON;");

            database.execSQL(createTableSettings, null);
            database.execSQL(createTableWorldData, null);
            database.execSQL(createTableLevelData, null);

        } catch (SQLException e) {
            Gdx.app.log("Exception in createTables", "This should not happen on an Android Device (This is fine on java.)");
            e.printStackTrace();
        }

    }
}
}

public static void load() {
    myManager = new AssetManager();

    SQLHelper.openDatabase();
    SQLHelper.createTables();       

    loadTextures(); 


}

And I am getting these type of exceptions registered by the logcat:

02-14 22:45:53.261: E/SqliteDatabaseCpp(578): sqlite3_open_v2("gameName", &handle, 6, NULL) failed

Failed to open the database. Closing it.

02-14 22:45:53.291: E/SQLiteDatabase(578):
android.database.sqlite.SQLiteCantOpenDatabaseException: unable to open database file

Please help me in this regard as I am new to libgdx/SQLite.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-17T20:11:57+00:00Added an answer on June 17, 2026 at 8:11 pm

    I tracked this question through the libGDX forums since I too was looking for a solution to something similar.

    Ultimately someone trying to implement SQLite into libGDX needs to create a wrapper so that something like SQLDroid can be used when running from an Android device, but the standard JDBC drivers can be used when running from the desktop.

    You can view the tutorial for creating this “wrapper” here.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

we are in process of developing google chrome extension, in which we need to
I'm in the in the process of developing an application for a client, which
I'm currently developing a networked 2D MMO-style game in which several thin clients (ran
I am in process of developing an Android tablet app using sqllite 3.7.4 which
We're in the process of developing a WCF REST web service which just receives
We are in the process of developing a client-server software (in C#, Net 2.0)which
I am in the process of developing several data entry forms that the client
I am in the process of developing an application (i.e.: base apk) which is
I am in the process of developing a .NET application which relies on an
I am developing a game and I'm having problems. Basically the idea is: Player

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.