ketai.data

## Class KetaiSQLite

- java.lang.Object
- - ketai.data.KetaiSQLite

-     public class KetaiSQLite
      extends java.lang.Object

  The Class KetaiSQLite provides access to the underlying SQLite database that every activity is provided with.

- - ### Constructor Summary

    Constructors
    Constructor and Description
    `KetaiSQLite(processing.core.PApplet p)` Instantiates a new ketai sqlite object.
    `KetaiSQLite(processing.core.PApplet p, java.lang.String dbname)` Instantiates a new ketai sqlite.

  - ### Method Summary

    All Methods Static Methods Instance Methods Concrete Methods
    Modifier and Type | Method and Description
    --- | ---
    `void` | `close()` Close the database.
    `boolean` | `connect()` Connect to the database.
    `void` | `deleteAllData()` Delete all data in our database.
    `void` | `dispose()` Dispose.
    `boolean` | `execute(java.lang.String _sql)` Execute an SQL statement
    `void` | `exportData(java.lang.String _targetDirectory)` Export data to a text file (tab delimited).
    `byte[]` | `getBlob(int _col)` Gets the blob value from a column in our resultset.
    `byte[]` | `getBlob(java.lang.String field)` Gets the blob value from a column in our resultset.
    `long` | `getDataCount()` Gets the data count (records in all tables in the database)
    `android.database.sqlite.SQLiteDatabase` | `getDb()` Gets the db from the sqlite service
    `double` | `getDouble(int _col)` Gets the double value from a column in our resultset
    `double` | `getDouble(java.lang.String field)` Gets the double value from a column in our resultset.
    `java.lang.String` | `getFieldMax(java.lang.String table, java.lang.String field)` Gets the field max value.
    `java.lang.String` | `getFieldMin(java.lang.String table, java.lang.String field)` Gets the field min value
    `java.lang.String[]` | `getFields(java.lang.String table)` Gets the field names
    `float` | `getFloat(int _col)` Gets the float value from a column in our resultset.
    `float` | `getFloat(java.lang.String field)` Gets the float value from a column in our resultset.
    `int` | `getInt(int _col)` Gets the int value from a column index in our resultset.
    `int` | `getInt(java.lang.String field)` Gets the int value from a column in our resultset.
    `long` | `getLong(int _col)` Gets the long value from a column in our resultset.
    `long` | `getLong(java.lang.String field)` Gets the long value from a column in our resultset.
    `java.lang.String` | `getPath()` Gets the path of the database
    `long` | `getRecordCount(java.lang.String table)` Gets the record count for the table.
    `java.lang.String` | `getString(int _col)` Gets the string value from a column in our resultset.
    `java.lang.String` | `getString(java.lang.String field)` Gets the string value from a column in our resultset.
    `java.lang.String[]` | `getTables()` Gets the table names in our database.
    `static boolean` | `load(processing.core.PApplet _context, java.lang.String filename, java.lang.String dbname)` Load - loads an external .sql file into the local SQLite database service.
    `boolean` | `next()` Next - move to the next object in our last result set.
    `boolean` | `query(java.lang.String _query)` Query the database.
    `boolean` | `tableExists(java.lang.String _table)` Check to see if the table exists.

    - ### Methods inherited from class java.lang.Object

      `clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

- - ### Constructor Detail

    - #### KetaiSQLite

          public KetaiSQLite(processing.core.PApplet p)

      Instantiates a new ketai sqlite object.
      Parameters:
        `context` - the context/PApplet/Activity using this class

    - #### KetaiSQLite

          public KetaiSQLite(processing.core.PApplet p,
                             java.lang.String dbname)

      Instantiates a new ketai sqlite.
      Parameters:
        `context` - the context
        `dbname` - the database name

  - ### Method Detail

    - #### load

          public static boolean load(processing.core.PApplet _context,
                                     java.lang.String filename,
                                     java.lang.String dbname)

      Load - loads an external .sql file into the local SQLite database service. Useful for populating data for an activity to use.
      Parameters:
        `_context` - the _context
        `filename` - the filename
        `dbname` - the dbname
      Returns:
        true, if successful

    - #### getPath

          public java.lang.String getPath()

      Gets the path of the database
      Returns:
        the path of the database

    - #### getDb

          public android.database.sqlite.SQLiteDatabase getDb()

      Gets the db from the sqlite service
      Returns:
        the db reference.

    - #### connect

          public boolean connect()

      Connect to the database.
      Returns:
        true, if successful

    - #### close

          public void close()

      Close the database.

    - #### dispose

          public void dispose()

      Dispose.

    - #### execute

          public boolean execute(java.lang.String _sql)

      Execute an SQL statement
      Parameters:
        `_sql` - the SQL statement to execute.
      Returns:
        true, if successful

    - #### query

          public boolean query(java.lang.String _query)

      Query the database.
      Parameters:
        `_query` - the query string
      Returns:
        true, if successful

    - #### next

          public boolean next()

      Next - move to the next object in our last result set.
      Returns:
        true, if successful

    - #### getDouble

          public double getDouble(int _col)

      Gets the double value from a column in our resultset
      Parameters:
        `_col` - the column/field index number
      Returns:
        the double

    - #### getDouble

          public double getDouble(java.lang.String field)

      Gets the double value from a column in our resultset.
      Parameters:
        `field` - the field name
      Returns:
        the double

    - #### getFloat

          public float getFloat(int _col)

      Gets the float value from a column in our resultset.
      Parameters:
        `_col` - the column index number
      Returns:
        the float

    - #### getFloat

          public float getFloat(java.lang.String field)

      Gets the float value from a column in our resultset.
      Parameters:
        `field` - the field mame
      Returns:
        the float

    - #### getInt

          public int getInt(int _col)

      Gets the int value from a column index in our resultset.
      Parameters:
        `_col` - the column index number
      Returns:
        the int

    - #### getInt

          public int getInt(java.lang.String field)

      Gets the int value from a column in our resultset.
      Parameters:
        `field` - the field name
      Returns:
        the int

    - #### getLong

          public long getLong(int _col)

      Gets the long value from a column in our resultset.
      Parameters:
        `_col` - the column/field index number
      Returns:
        the long

    - #### getLong

          public long getLong(java.lang.String field)

      Gets the long value from a column in our resultset.
      Parameters:
        `field` - the field/column name
      Returns:
        the long

    - #### getBlob

          public byte[] getBlob(int _col)

      Gets the blob value from a column in our resultset.
      Parameters:
        `_col` - the column/field index number
      Returns:
        the blob

    - #### getBlob

          public byte[] getBlob(java.lang.String field)

      Gets the blob value from a column in our resultset.
      Parameters:
        `field` - the field/column name
      Returns:
        the blob

    - #### getString

          public java.lang.String getString(int _col)

      Gets the string value from a column in our resultset.
      Parameters:
        `_col` - the column/field index number
      Returns:
        the string

    - #### getString

          public java.lang.String getString(java.lang.String field)

      Gets the string value from a column in our resultset.
      Parameters:
        `field` - the field/column name
      Returns:
        the string

    - #### getTables

          public java.lang.String[] getTables()

      Gets the table names in our database.
      Returns:
        the names of the tables in the database

    - #### getFields

          public java.lang.String[] getFields(java.lang.String table)

      Gets the field names
      Parameters:
        `table` - the table name
      Returns:
        the fields

    - #### getFieldMin

          public java.lang.String getFieldMin(java.lang.String table,
                                              java.lang.String field)

      Gets the field min value
      Parameters:
        `table` - the table name
        `field` - the field name
      Returns:
        the field min value

    - #### getFieldMax

          public java.lang.String getFieldMax(java.lang.String table,
                                              java.lang.String field)

      Gets the field max value.
      Parameters:
        `table` - the table name
        `field` - the field name
      Returns:
        the field max value

    - #### getRecordCount

          public long getRecordCount(java.lang.String table)

      Gets the record count for the table.
      Parameters:
        `table` - the table name
      Returns:
        the record count

    - #### getDataCount

          public long getDataCount()

      Gets the data count (records in all tables in the database)
      Returns:
        the data count

    - #### tableExists

          public boolean tableExists(java.lang.String _table)

      Check to see if the table exists.
      Parameters:
        `_table` - the table name
      Returns:
        true, if successful

    - #### exportData

          public void exportData(java.lang.String _targetDirectory)
                          throws java.io.IOException

      Export data to a text file (tab delimited).
      Parameters:
        `_targetDirectory` - the target directory
      Throws:
        `java.io.IOException` - Signals that an I/O exception has occurred.

    - #### deleteAllData

          public void deleteAllData()

      Delete all data in our database. Deletes all tables.