Example usage for com.badlogic.gdx.sql SQLiteGdxDatabase openOrCreateDatabase

List of usage examples for com.badlogic.gdx.sql SQLiteGdxDatabase openOrCreateDatabase

Introduction

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

Prototype

public void openOrCreateDatabase() throws SQLiteGdxException;

Source Link

Document

Opens an already existing database or creates a new database if it doesn't already exist.

Usage

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

License:Open Source License

public static int getCacheCountInDB(String absolutePath) {
    try {/*from   www  . jav  a  2  s . c o m*/
        SQLiteGdxDatabase tempDB = SQLiteGdxDatabaseFactory.getNewDatabase(Gdx.files.absolute(absolutePath));
        tempDB.openOrCreateDatabase();
        SQLiteGdxDatabaseCursor result = tempDB.rawQuery("SELECT COUNT(*) FROM caches", null);
        result.moveToFirst();
        int count = result.getInt(1);
        result.close();
        tempDB.closeDatabase();
        return count;
    } catch (Exception exc) {
        return -1;
    }
}