Example usage for android.database.sqlite SQLiteDatabase isReadOnly

List of usage examples for android.database.sqlite SQLiteDatabase isReadOnly

Introduction

In this page you can find the example usage for android.database.sqlite SQLiteDatabase isReadOnly.

Prototype

public boolean isReadOnly() 

Source Link

Document

Returns true if the database is opened as read only.

Usage

From source file:uk.org.rivernile.edinburghbustracker.android.SettingsDatabase.java

/**
 * Clean up alerts. This removes any alerts which are older than 1 hour.
 * /* ww  w .j  av  a2s . c  o m*/
 * @param db The SQLiteDatabase on which we are operating.
 */
public void cleanupAlerts(final SQLiteDatabase db) {
    if (!db.isReadOnly()) {
        db.delete(ALERTS_TABLE, ALERTS_TIME_ADDED + " < ?",
                new String[] { String.valueOf(System.currentTimeMillis() - 3600000) });
    }
}

From source file:project.cs.netinfservice.database.IODatabase.java

/**
 * Called when the database has been opened. The implementation should check isReadOnly() 
 * before updating the database. This method is called after the database connection has 
 * been configured and after the database schema has been created, upgraded or downgraded 
 * as necessary. If the database connection must be configured in some way before the schema 
 * is created, upgraded, or downgraded, do it in onConfigure(SQLiteDatabase) instead.
 *//*ww w .j  a v a2 s .  c  o  m*/
@Override
public void onOpen(SQLiteDatabase db) {
    super.onOpen(db);

    // Checks if the database is read-only or not
    if (!db.isReadOnly()) {
        // Enable foreign key constraints
        db.execSQL("PRAGMA foreign_keys=ON;");
    }
}

From source file:org.mitre.svmp.common.DatabaseHandler.java

@Override
public void onOpen(SQLiteDatabase db) {
    super.onOpen(db);
    if (!db.isReadOnly()) {
        // Enable foreign key constraints
        db.execSQL("PRAGMA foreign_keys=ON;");
    }/*from  w ww.ja v  a  2  s .  c o  m*/
}

From source file:org.totschnig.myexpenses.provider.TransactionDatabase.java

@Override
public void onOpen(SQLiteDatabase db) {
    super.onOpen(db);
    //since API 16 we could use onConfigure to enable foreign keys
    //which is run before onUpgrade
    //but this makes upgrades more difficult, since then you have to maintain the constraint in
    //each step of a multi statement upgrade with table rename
    //we stick to doing upgrades with foreign keys disabled which forces us
    //to take care of ensuring consistency during upgrades
    if (!db.isReadOnly()) {
        db.execSQL("PRAGMA foreign_keys=ON;");
    }// w  ww . j a  va 2s.co  m
    try {
        db.delete(TABLE_TRANSACTIONS, KEY_STATUS + " = " + STATUS_UNCOMMITTED, null);
    } catch (SQLiteException e) {
        AcraHelper.report(e, DbUtils.getTableDetails(db.query("sqlite_master", new String[] { "name", "sql" },
                "type = 'table'", null, null, null, null)));
    }
}