FileDocCategorySizeDatePackage
SQLiteDatabaseConfiguration.javaAPI DocAndroid 5.1 API5068Thu Mar 12 22:22:10 GMT 2015android.database.sqlite

SQLiteDatabaseConfiguration

public final class SQLiteDatabaseConfiguration extends Object
Describes how to configure a database.

The purpose of this object is to keep track of all of the little configuration settings that are applied to a database after it is opened so that they can be applied to all connections in the connection pool uniformly.

Each connection maintains its own copy of this object so it can keep track of which settings have already been applied.

hide

Fields Summary
private static final Pattern
EMAIL_IN_DB_PATTERN
public static final String
MEMORY_DB_PATH
Special path used by in-memory databases.
public final String
path
The database path.
public final String
label
The label to use to describe the database when it appears in logs. This is derived from the path but is stripped to remove PII.
public int
openFlags
The flags used to open the database.
public int
maxSqlCacheSize
The maximum size of the prepared statement cache for each database connection. Must be non-negative. Default is 25.
public Locale
locale
The database locale. Default is the value returned by {@link Locale#getDefault()}.
public boolean
foreignKeyConstraintsEnabled
True if foreign key constraints are enabled. Default is false.
public final ArrayList
customFunctions
The custom functions to register.
Constructors Summary
public SQLiteDatabaseConfiguration(String path, int openFlags)
Creates a database configuration with the required parameters for opening a database and default values for all other parameters.

param
path The database path.
param
openFlags Open flags for the database, such as {@link SQLiteDatabase#OPEN_READWRITE}.


                                            
         
        if (path == null) {
            throw new IllegalArgumentException("path must not be null.");
        }

        this.path = path;
        label = stripPathForLogs(path);
        this.openFlags = openFlags;

        // Set default values for optional parameters.
        maxSqlCacheSize = 25;
        locale = Locale.getDefault();
    
public SQLiteDatabaseConfiguration(SQLiteDatabaseConfiguration other)
Creates a database configuration as a copy of another configuration.

param
other The other configuration.

        if (other == null) {
            throw new IllegalArgumentException("other must not be null.");
        }

        this.path = other.path;
        this.label = other.label;
        updateParametersFrom(other);
    
Methods Summary
public booleanisInMemoryDb()
Returns true if the database is in-memory.

return
True if the database is in-memory.

        return path.equalsIgnoreCase(MEMORY_DB_PATH);
    
private static java.lang.StringstripPathForLogs(java.lang.String path)

        if (path.indexOf('@") == -1) {
            return path;
        }
        return EMAIL_IN_DB_PATTERN.matcher(path).replaceAll("XX@YY");
    
public voidupdateParametersFrom(android.database.sqlite.SQLiteDatabaseConfiguration other)
Updates the non-immutable parameters of this configuration object from the other configuration object.

param
other The object from which to copy the parameters.

        if (other == null) {
            throw new IllegalArgumentException("other must not be null.");
        }
        if (!path.equals(other.path)) {
            throw new IllegalArgumentException("other configuration must refer to "
                    + "the same database.");
        }

        openFlags = other.openFlags;
        maxSqlCacheSize = other.maxSqlCacheSize;
        locale = other.locale;
        foreignKeyConstraintsEnabled = other.foreignKeyConstraintsEnabled;
        customFunctions.clear();
        customFunctions.addAll(other.customFunctions);