Example usage for com.badlogic.gdx.sql SQLiteGdxException SQLiteGdxException

List of usage examples for com.badlogic.gdx.sql SQLiteGdxException SQLiteGdxException

Introduction

In this page you can find the example usage for com.badlogic.gdx.sql SQLiteGdxException SQLiteGdxException.

Prototype

public SQLiteGdxException(Throwable t) 

Source Link

Usage

From source file:de.longri.cachebox3.sqlite.Database.java

License:Open Source License

public boolean StartUp(FileHandle databasePath) throws SQLiteGdxException {

    FileHandle parentDirectory = databasePath.parent();

    if (!parentDirectory.exists()) {
        throw new SQLiteGdxException(
                "Directory for DB doesn't exist: " + parentDirectory.file().getAbsolutePath());
    }//w  w  w.jav a2s .com

    log.debug("StartUp Database: " + Utils.GetFileName(databasePath));
    if (myDB != null) {
        log.debug("Database is open ");
        if (this.databasePath.file().getAbsolutePath().equals(databasePath.file().getAbsolutePath())) {
            log.debug("Database is the same");
            if (!myDB.isOpen()) {
                log.debug("Database was close so open now");
                myDB.openOrCreateDatabase();
            }

            // is open
            return true;
        }
        log.debug("Database is changed! close " + Utils.GetFileName(this.databasePath));
        if (myDB.isOpen())
            myDB.closeDatabase();
        myDB = null;
    }

    this.databasePath = databasePath;
    log.debug("Initial database: " + Utils.GetFileName(databasePath));
    Initialize();

    int databaseSchemeVersion = GetDatabaseSchemeVersion();
    log.debug("DatabaseSchemeVersion: " + databaseSchemeVersion);
    if (databaseSchemeVersion < latestDatabaseChange) {
        log.debug("Alter Database to SchemeVersion: " + latestDatabaseChange);
        AlterDatabase(databaseSchemeVersion);
        SetDatabaseSchemeVersion();
    }

    if (databaseType == DatabaseType.CacheBox) { // create or load DatabaseId for each
        DatabaseId = ReadConfigLong("DatabaseId");
        if (DatabaseId <= 0) {
            DatabaseId = new Date().getTime();
            WriteConfigLong("DatabaseId", DatabaseId);
        }
        // Read MasterDatabaseId. If MasterDatabaseId > 0 -> This database
        // is connected to the Replications Master of WinCB
        // In this case changes of Waypoints, Solvertext, Notes must be
        // noted in the Table Replication...
        MasterDatabaseId = ReadConfigLong("MasterDatabaseId");
    }
    return true;
}