Class SQLiteUtils

  • All Implemented Interfaces:
    java.io.Serializable

    public class SQLiteUtils
    extends java.lang.Object
    implements java.io.Serializable
    This utility class is designed to take an SQLite database, and manage connections for you. It is designed to be serializable, such that when it is deserialized/unserialized, everything just works (tm).
    See Also:
    Serialized Form
    • Field Summary

      Fields 
      Modifier and Type Field Description
      static java.lang.String MEMORY_DB
      The db "file" for in memory databases
    • Constructor Summary

      Constructors 
      Constructor Description
      SQLiteUtils​(ExternalDataFetcher fileFetcher, java.lang.String database, java.lang.String table)
      Initialize a database
    • Method Summary

      All Methods Static Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      void clear()
      Clear cached data
      java.lang.String getFile()
      Get the file for the database
      java.util.Map<java.lang.String,​java.lang.Object> getRows​(java.util.Map<java.lang.String,​java.lang.String> values)
      Get row(s) from the table
      static boolean isValidDatabase​(java.lang.String database)
      Check that a database exists
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Field Detail

      • MEMORY_DB

        public static final java.lang.String MEMORY_DB
        The db "file" for in memory databases
        See Also:
        Constant Field Values
    • Constructor Detail

      • SQLiteUtils

        public SQLiteUtils​(ExternalDataFetcher fileFetcher,
                           java.lang.String database,
                           java.lang.String table)
        Initialize a database
        Parameters:
        fileFetcher - The file fetcher to use to get files
        database - A database to use (should be checked first with isValidDatabase(java.lang.String))
        table - The default table to use, if a passed table is null or blank
    • Method Detail

      • isValidDatabase

        public static boolean isValidDatabase​(java.lang.String database)
        Check that a database exists
        Parameters:
        database - The location of the database (may be ":memory:")
        Returns:
        true if the database file exists
      • clear

        public void clear()
        Clear cached data
      • getFile

        public java.lang.String getFile()
        Get the file for the database
        Returns:
        The path for the database
      • getRows

        public java.util.Map<java.lang.String,​java.lang.Object> getRows​(java.util.Map<java.lang.String,​java.lang.String> values)
        Get row(s) from the table
        Parameters:
        values - The values to filter by (column name, value )
        Returns:
        The rows that match for the query (SELECT * FROM {table} WHERE {key1}={value1} AND ...)