Class GeoPackageDatabase

java.lang.Object
mil.nga.geopackage.db.GeoPackageDatabase
All Implemented Interfaces:
GeoPackageSQLiteDatabase

public class GeoPackageDatabase extends Object implements GeoPackageSQLiteDatabase
GeoPackage database wrapper around SQLiteDatabase to quote table and column names
Since:
1.3.1
  • Constructor Details

    • GeoPackageDatabase

      public GeoPackageDatabase(android.database.sqlite.SQLiteDatabase db)
      Constructor
      Parameters:
      db - database
    • GeoPackageDatabase

      public GeoPackageDatabase(android.database.sqlite.SQLiteDatabase db, GeoPackageCursorFactory cursorFactory)
      Constructor
      Parameters:
      db - database
      cursorFactory - cursor factory
      Since:
      3.4.0
    • GeoPackageDatabase

      public GeoPackageDatabase(android.database.sqlite.SQLiteDatabase db, boolean writable, GeoPackageCursorFactory cursorFactory)
      Constructor
      Parameters:
      db - database
      writable - writable flag
      cursorFactory - cursor factory
      Since:
      3.4.0
    • GeoPackageDatabase

      public GeoPackageDatabase(GeoPackageDatabase database)
      Copy constructor
      Parameters:
      database - GeoPackage database
      Since:
      3.4.0
  • Method Details

    • getActive

      public GeoPackageSQLiteDatabase getActive()
      Get the active connection
      Returns:
      active connection
      Since:
      3.4.0
    • getAndroidSQLiteDatabase

      public AndroidSQLiteDatabase getAndroidSQLiteDatabase()
      Get the Android SQLite Database connection
      Returns:
      connection
      Since:
      3.4.0
    • getAndroidBindingsSQLiteDatabase

      public AndroidBindingsSQLiteDatabase getAndroidBindingsSQLiteDatabase()
      Get the Android Bindings SQLite Database connection
      Returns:
      connection
      Since:
      3.4.0
    • getDb

      public android.database.sqlite.SQLiteDatabase getDb()
      Get the SQLite database connection
      Returns:
      connection
    • getBindingsDb

      public org.sqlite.database.sqlite.SQLiteDatabase getBindingsDb()
      Get the SQLite bindings database connection
      Returns:
      connection
      Since:
      3.4.0
    • isUseBindings

      public boolean isUseBindings()
      Is SQLite Android Bindings connection enabled
      Returns:
      true if using bindings
      Since:
      3.4.0
    • getCursorFactory

      public GeoPackageCursorFactory getCursorFactory()
      Get the cursor factory
      Returns:
      cusror factory
      Since:
      4.0.0
    • isWritable

      public boolean isWritable()
      Is the SQLite database connection writable
      Returns:
      true if writable
      Since:
      3.4.0
    • isBindingsWritable

      public boolean isBindingsWritable()
      Is the SQLite bindings database connection writable
      Returns:
      true if writable
      Since:
      3.4.0
    • setUseBindings

      public boolean setUseBindings(boolean useBindings)
      Set the active SQLite connection as the bindings or standard
      Parameters:
      useBindings - true to use bindings connection, false for standard
      Returns:
      previous bindings value
      Since:
      3.4.0
    • copy

      public GeoPackageDatabase copy()
      Copy the database, maintaining the same connections but with the ability to change the active used connection
      Returns:
      database
      Since:
      3.4.0
    • execSQL

      public void execSQL(String sql) throws android.database.SQLException
      Execute SQL
      Specified by:
      execSQL in interface GeoPackageSQLiteDatabase
      Parameters:
      sql - sql command
      Throws:
      android.database.SQLException
      See Also:
      • SQLiteDatabase.execSQL(String)
    • beginTransaction

      public void beginTransaction()
      Begin a transaction
      Specified by:
      beginTransaction in interface GeoPackageSQLiteDatabase
    • endTransaction

      public void endTransaction()
      End a transaction as successful
      Specified by:
      endTransaction in interface GeoPackageSQLiteDatabase
    • endTransaction

      public void endTransaction(boolean successful)
      End a transaction
      Specified by:
      endTransaction in interface GeoPackageSQLiteDatabase
      Parameters:
      successful - true to commit, false to rollback
    • endAndBeginTransaction

      public void endAndBeginTransaction()
      End a transaction as successful and begin a new transaction
      Specified by:
      endAndBeginTransaction in interface GeoPackageSQLiteDatabase
    • inTransaction

      public boolean inTransaction()
      Determine if currently within a transaction
      Specified by:
      inTransaction in interface GeoPackageSQLiteDatabase
      Returns:
      true if in transaction
    • delete

      public int delete(String table, String whereClause, String[] whereArgs)
      Delete from table
      Specified by:
      delete in interface GeoPackageSQLiteDatabase
      Parameters:
      table - table name
      whereClause - where clause
      whereArgs - where arguments
      Returns:
      deleted rows
      See Also:
      • SQLiteDatabase.delete(String, String, String[])
    • rawQuery

      public android.database.Cursor rawQuery(String sql, String[] selectionArgs)
      Raw query
      Specified by:
      rawQuery in interface GeoPackageSQLiteDatabase
      Parameters:
      sql - sql command
      selectionArgs - selection arguments
      Returns:
      cursor
      See Also:
      • SQLiteDatabase.rawQuery(String, String[])
    • rawQueryWithFactory

      public android.database.Cursor rawQueryWithFactory(GeoPackageCursorFactory cursorFactory, String sql, String[] selectionArgs, String editTable)
      Raw query with factory
      Specified by:
      rawQueryWithFactory in interface GeoPackageSQLiteDatabase
      Parameters:
      cursorFactory - cursor factory
      sql - sql command
      selectionArgs - selection arguments
      editTable - edit table name
      Returns:
      cursor
      See Also:
      • SQLiteDatabase.rawQueryWithFactory(SQLiteDatabase.CursorFactory, String, String[], String)
    • close

      public void close()
      Close the connection
      Specified by:
      close in interface GeoPackageSQLiteDatabase
      See Also:
      • SQLiteClosable.close()
    • query

      public android.database.Cursor query(String table, String[] columns, String selection, String[] selectionArgs, String groupBy, String having, String orderBy)
      Query the table
      Specified by:
      query in interface GeoPackageSQLiteDatabase
      Parameters:
      table - table name
      columns - columns
      selection - selection
      selectionArgs - selection arguments
      groupBy - group by
      having - having
      orderBy - order by
      Returns:
      cursor
      See Also:
      • SQLiteDatabase.query(String, String[], String, String[], String, String, String)
    • query

      public android.database.Cursor query(String table, String[] columns, String[] columnsAs, String selection, String[] selectionArgs, String groupBy, String having, String orderBy)
      Query the table
      Specified by:
      query in interface GeoPackageSQLiteDatabase
      Parameters:
      table - table name
      columns - columns
      columnsAs - columns as
      selection - selection
      selectionArgs - selection arguments
      groupBy - group by
      having - having
      orderBy - order by
      Returns:
      cursor
      See Also:
      • SQLiteDatabase.query(String, String[], String, String[], String, String, String)
    • query

      public android.database.Cursor query(String table, String[] columns, String selection, String[] selectionArgs, String groupBy, String having, String orderBy, String limit)
      Query the table
      Specified by:
      query in interface GeoPackageSQLiteDatabase
      Parameters:
      table - table name
      columns - columns
      selection - selection
      selectionArgs - selection arguments
      groupBy - group by
      having - having
      orderBy - order by
      limit - limit
      Returns:
      cursor
      See Also:
      • SQLiteDatabase.query(String, String[], String, String[], String, String, String, String)
    • query

      public android.database.Cursor query(String table, String[] columns, String[] columnsAs, String selection, String[] selectionArgs, String groupBy, String having, String orderBy, String limit)
      Query the table
      Specified by:
      query in interface GeoPackageSQLiteDatabase
      Parameters:
      table - table name
      columns - columns
      columnsAs - columns as
      selection - selection
      selectionArgs - selection arguments
      groupBy - group by
      having - having
      orderBy - order by
      limit - limit
      Returns:
      cursor
      See Also:
      • SQLiteDatabase.query(String, String[], String, String[], String, String, String, String)
    • query

      public android.database.Cursor query(boolean distinct, String table, String[] columns, String selection, String[] selectionArgs, String groupBy, String having, String orderBy, String limit)
      Query the table
      Specified by:
      query in interface GeoPackageSQLiteDatabase
      Parameters:
      distinct - distinct flag
      table - table name
      columns - columns
      selection - selection
      selectionArgs - selection arguments
      groupBy - group by
      having - having
      orderBy - order by
      limit - limit
      Returns:
      cursor
      See Also:
      • SQLiteDatabase.query(boolean, String, String[], String, String[], String, String, String, String)
    • update

      public int update(String table, android.content.ContentValues values, String whereClause, String[] whereArgs)
      Update the table
      Specified by:
      update in interface GeoPackageSQLiteDatabase
      Parameters:
      table - table name
      values - content values
      whereClause - where clause
      whereArgs - where arguments
      Returns:
      updated rows
      See Also:
      • SQLiteDatabase.update(String, ContentValues, String, String[])
    • insertOrThrow

      public long insertOrThrow(String table, String nullColumnHack, android.content.ContentValues values) throws android.database.SQLException
      Insert into a table
      Specified by:
      insertOrThrow in interface GeoPackageSQLiteDatabase
      Parameters:
      table - table name
      nullColumnHack - null column hack
      values - content values
      Returns:
      row id
      Throws:
      android.database.SQLException
      See Also:
      • SQLiteDatabase.insertOrThrow(String, String, ContentValues)
    • insert

      public long insert(String table, String nullColumnHack, android.content.ContentValues values)
      Insert into a table
      Specified by:
      insert in interface GeoPackageSQLiteDatabase
      Parameters:
      table - table name
      nullColumnHack - null column hack
      values - content values
      Returns:
      row id
      See Also:
      • SQLiteDatabase.insert(String, String, ContentValues)