com.activeandroid.util.SQLiteUtils Java Examples

The following examples show how to use com.activeandroid.util.SQLiteUtils. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: StepCounter.java    From xDrip with GNU General Public License v3.0 6 votes vote down vote up
private static void fixUpTable() {
    if (patched) return;
    String[] patchup = {
            "CREATE TABLE PebbleMovement (_id INTEGER PRIMARY KEY AUTOINCREMENT);",
            "ALTER TABLE PebbleMovement ADD COLUMN timestamp INTEGER;",
            "ALTER TABLE PebbleMovement ADD COLUMN metric INTEGER;",
            "CREATE UNIQUE INDEX index_PebbleMovement_timestamp on PebbleMovement(timestamp);"};

    for (String patch : patchup) {
        try {
            SQLiteUtils.execSql(patch);
            //  UserError.Log.e(TAG, "Processed patch should not have succeeded!!: " + patch);
        } catch (Exception e) {
            //  UserError.Log.d(TAG, "Patch: " + patch + " generated exception as it should: " + e.toString());
        }
    }
    patched = true;
}
 
Example #2
Source File: BloodTest.java    From xDrip-plus with GNU General Public License v3.0 6 votes vote down vote up
private static void fixUpTable() {
    if (patched) return;
    final String[] patchup = {
            "CREATE TABLE BloodTest (_id INTEGER PRIMARY KEY AUTOINCREMENT);",
            "ALTER TABLE BloodTest ADD COLUMN timestamp INTEGER;",
            "ALTER TABLE BloodTest ADD COLUMN created_timestamp INTEGER;",
            "ALTER TABLE BloodTest ADD COLUMN state INTEGER;",
            "ALTER TABLE BloodTest ADD COLUMN mgdl REAL;",
            "ALTER TABLE BloodTest ADD COLUMN source TEXT;",
            "ALTER TABLE BloodTest ADD COLUMN uuid TEXT;",
            "CREATE UNIQUE INDEX index_Bloodtest_uuid on BloodTest(uuid);",
            "CREATE UNIQUE INDEX index_Bloodtest_timestamp on BloodTest(timestamp);",
            "CREATE INDEX index_Bloodtest_created_timestamp on BloodTest(created_timestamp);",
            "CREATE INDEX index_Bloodtest_state on BloodTest(state);"};

    for (String patch : patchup) {
        try {
            SQLiteUtils.execSql(patch);
            //  UserError.Log.e(TAG, "Processed patch should not have succeeded!!: " + patch);
        } catch (Exception e) {
            //  UserError.Log.d(TAG, "Patch: " + patch + " generated exception as it should: " + e.toString());
        }
    }
    patched = true;
}
 
Example #3
Source File: Treatments.java    From xDrip-plus with GNU General Public License v3.0 6 votes vote down vote up
private static void fixUpTable() {
    if (patched) return;
    String[] patchup = {
            "CREATE TABLE Treatments (_id INTEGER PRIMARY KEY AUTOINCREMENT);",
            "ALTER TABLE Treatments ADD COLUMN timestamp INTEGER;",
            "ALTER TABLE Treatments ADD COLUMN uuid TEXT;",
            "ALTER TABLE Treatments ADD COLUMN eventType TEXT;",
            "ALTER TABLE Treatments ADD COLUMN enteredBy TEXT;",
            "ALTER TABLE Treatments ADD COLUMN notes TEXT;",
            "ALTER TABLE Treatments ADD COLUMN created_at TEXT;",
            "ALTER TABLE Treatments ADD COLUMN insulin REAL;",
            "ALTER TABLE Treatments ADD COLUMN insulinJSON TEXT;",
            "ALTER TABLE Treatments ADD COLUMN carbs REAL;",
            "CREATE INDEX index_Treatments_timestamp on Treatments(timestamp);",
            "CREATE UNIQUE INDEX index_Treatments_uuid on Treatments(uuid);"};

    for (String patch : patchup) {
        try {
            SQLiteUtils.execSql(patch);
            //Log.e(TAG, "Processed patch should not have succeeded!!: " + patch);
        } catch (Exception e) {
            // Log.d(TAG, "Patch: " + patch + " generated exception as it should: " + e.toString());
        }
    }
    patched = true;
}
 
Example #4
Source File: HeartRate.java    From xDrip-plus with GNU General Public License v3.0 6 votes vote down vote up
private static void fixUpTable() {
    if (patched) return;
    String[] patchup = {
            "CREATE TABLE HeartRate (_id INTEGER PRIMARY KEY AUTOINCREMENT);",
            "ALTER TABLE HeartRate ADD COLUMN timestamp INTEGER;",
            "ALTER TABLE HeartRate ADD COLUMN bpm INTEGER;",
            "ALTER TABLE HeartRate ADD COLUMN accuracy INTEGER;",
            "CREATE UNIQUE INDEX index_HeartRate_timestamp on HeartRate(timestamp);"};

    for (String patch : patchup) {
        try {
            SQLiteUtils.execSql(patch);
            //  UserError.Log.e(TAG, "Processed patch should not have succeeded!!: " + patch);
        } catch (Exception e) {
            //  UserError.Log.d(TAG, "Patch: " + patch + " generated exception as it should: " + e.toString());
        }
    }
    patched = true;
}
 
Example #5
Source File: BgReading.java    From xDrip-plus with GNU General Public License v3.0 6 votes vote down vote up
public synchronized static void updateDB() {
    final String[] updates = new String[]{"ALTER TABLE BgReadings ADD COLUMN dg_mgdl REAL;",
            "ALTER TABLE BgReadings ADD COLUMN dg_slope REAL;",
            "ALTER TABLE BgReadings ADD COLUMN dg_delta_name TEXT;",
            "ALTER TABLE BgReadings ADD COLUMN source_info TEXT;"};
    for (String patch : updates) {
        try {
            SQLiteUtils.execSql(patch);
        } catch (Exception e) {
        }
    }

    // needs different handling on wear
    if (JoH.areWeRunningOnAndroidWear()) {
        BgSendQueue.emptyQueue();
        SqliteRejigger.rejigSchema("BgReadings", "uuid TEXT UNIQUE ON CONFLICT FAIL", "uuid TEXT UNIQUE ON CONFLICT REPLACE");
        SqliteRejigger.rejigSchema("BgReadings", "uuid TEXT UNIQUE ON CONFLICT IGNORE", "uuid TEXT UNIQUE ON CONFLICT REPLACE");
        SqliteRejigger.rejigSchema("BgSendQueue", "BgReadings_temp", "BgReadings");
    }

}
 
Example #6
Source File: HeartRate.java    From xDrip-plus with GNU General Public License v3.0 6 votes vote down vote up
private static void fixUpTable() {
    if (patched) return;
    String[] patchup = {
            "CREATE TABLE HeartRate (_id INTEGER PRIMARY KEY AUTOINCREMENT);",
            "ALTER TABLE HeartRate ADD COLUMN timestamp INTEGER;",
            "ALTER TABLE HeartRate ADD COLUMN bpm INTEGER;",
            "ALTER TABLE HeartRate ADD COLUMN accuracy INTEGER;",
            "CREATE UNIQUE INDEX index_HeartRate_timestamp on HeartRate(timestamp);"};

    for (String patch : patchup) {
        try {
            SQLiteUtils.execSql(patch);
            //  UserError.Log.e(TAG, "Processed patch should not have succeeded!!: " + patch);
        } catch (Exception e) {
            //  UserError.Log.d(TAG, "Patch: " + patch + " generated exception as it should: " + e.toString());
        }
    }
    patched = true;
}
 
Example #7
Source File: StepCounter.java    From xDrip-plus with GNU General Public License v3.0 6 votes vote down vote up
private static void fixUpTable() {
    if (patched) return;
    String[] patchup = {
            "CREATE TABLE PebbleMovement (_id INTEGER PRIMARY KEY AUTOINCREMENT);",
            "ALTER TABLE PebbleMovement ADD COLUMN timestamp INTEGER;",
            "ALTER TABLE PebbleMovement ADD COLUMN metric INTEGER;",
            "CREATE UNIQUE INDEX index_PebbleMovement_timestamp on PebbleMovement(timestamp);"};

    for (String patch : patchup) {
        try {
            SQLiteUtils.execSql(patch);
            //  UserError.Log.e(TAG, "Processed patch should not have succeeded!!: " + patch);
        } catch (Exception e) {
            //  UserError.Log.d(TAG, "Patch: " + patch + " generated exception as it should: " + e.toString());
        }
    }
    patched = true;
}
 
Example #8
Source File: PebbleMovement.java    From xDrip-plus with GNU General Public License v3.0 6 votes vote down vote up
private static void fixUpTable() {
    if (patched) return;
    String[] patchup = {
            "CREATE TABLE PebbleMovement (_id INTEGER PRIMARY KEY AUTOINCREMENT);",
            "ALTER TABLE PebbleMovement ADD COLUMN timestamp INTEGER;",
            "ALTER TABLE PebbleMovement ADD COLUMN metric INTEGER;",
            "CREATE UNIQUE INDEX index_PebbleMovement_timestamp on PebbleMovement(timestamp);"};

    for (String patch : patchup) {
        try {
            SQLiteUtils.execSql(patch);
            //  UserError.Log.e(TAG, "Processed patch should not have succeeded!!: " + patch);
        } catch (Exception e) {
            //  UserError.Log.d(TAG, "Patch: " + patch + " generated exception as it should: " + e.toString());
        }
    }
    patched = true;
}
 
Example #9
Source File: BloodTest.java    From xDrip-plus with GNU General Public License v3.0 6 votes vote down vote up
private static void fixUpTable() {
    if (patched) return;
    final String[] patchup = {
            "CREATE TABLE BloodTest (_id INTEGER PRIMARY KEY AUTOINCREMENT);",
            "ALTER TABLE BloodTest ADD COLUMN timestamp INTEGER;",
            "ALTER TABLE BloodTest ADD COLUMN created_timestamp INTEGER;",
            "ALTER TABLE BloodTest ADD COLUMN state INTEGER;",
            "ALTER TABLE BloodTest ADD COLUMN mgdl REAL;",
            "ALTER TABLE BloodTest ADD COLUMN source TEXT;",
            "ALTER TABLE BloodTest ADD COLUMN uuid TEXT;",
            "CREATE UNIQUE INDEX index_Bloodtest_uuid on BloodTest(uuid);",
            "CREATE UNIQUE INDEX index_Bloodtest_timestamp on BloodTest(timestamp);",
            "CREATE INDEX index_Bloodtest_created_timestamp on BloodTest(created_timestamp);",
            "CREATE INDEX index_Bloodtest_state on BloodTest(state);"};

    for (String patch : patchup) {
        try {
            SQLiteUtils.execSql(patch);
            //  UserError.Log.e(TAG, "Processed patch should not have succeeded!!: " + patch);
        } catch (Exception e) {
            //  UserError.Log.d(TAG, "Patch: " + patch + " generated exception as it should: " + e.toString());
        }
    }
    patched = true;
}
 
Example #10
Source File: BgReading.java    From xDrip-plus with GNU General Public License v3.0 6 votes vote down vote up
public synchronized static void updateDB() {
    final String[] updates = new String[]{"ALTER TABLE BgReadings ADD COLUMN dg_mgdl REAL;",
            "ALTER TABLE BgReadings ADD COLUMN dg_slope REAL;",
            "ALTER TABLE BgReadings ADD COLUMN dg_delta_name TEXT;",
            "ALTER TABLE BgReadings ADD COLUMN source_info TEXT;"};
    for (String patch : updates) {
        try {
            SQLiteUtils.execSql(patch);
        } catch (Exception e) {
        }
    }

    // needs different handling on wear
    if (JoH.areWeRunningOnAndroidWear()) {
        BgSendQueue.emptyQueue();
        SqliteRejigger.rejigSchema("BgReadings", "uuid TEXT UNIQUE ON CONFLICT FAIL", "uuid TEXT UNIQUE ON CONFLICT REPLACE");
        SqliteRejigger.rejigSchema("BgReadings", "uuid TEXT UNIQUE ON CONFLICT IGNORE", "uuid TEXT UNIQUE ON CONFLICT REPLACE");
        SqliteRejigger.rejigSchema("BgSendQueue", "BgReadings_temp", "BgReadings");
    }

}
 
Example #11
Source File: BgReading.java    From xDrip with GNU General Public License v3.0 6 votes vote down vote up
public synchronized static void updateDB() {
    final String[] updates = new String[]{"ALTER TABLE BgReadings ADD COLUMN dg_mgdl REAL;",
            "ALTER TABLE BgReadings ADD COLUMN dg_slope REAL;",
            "ALTER TABLE BgReadings ADD COLUMN dg_delta_name TEXT;",
            "ALTER TABLE BgReadings ADD COLUMN source_info TEXT;"};
    for (String patch : updates) {
        try {
            SQLiteUtils.execSql(patch);
        } catch (Exception e) {
        }
    }

    // needs different handling on wear
    if (JoH.areWeRunningOnAndroidWear()) {
        BgSendQueue.emptyQueue();
        SqliteRejigger.rejigSchema("BgReadings", "uuid TEXT UNIQUE ON CONFLICT FAIL", "uuid TEXT UNIQUE ON CONFLICT REPLACE");
        SqliteRejigger.rejigSchema("BgReadings", "uuid TEXT UNIQUE ON CONFLICT IGNORE", "uuid TEXT UNIQUE ON CONFLICT REPLACE");
        SqliteRejigger.rejigSchema("BgSendQueue", "BgReadings_temp", "BgReadings");
    }

}
 
Example #12
Source File: HeartRate.java    From xDrip with GNU General Public License v3.0 6 votes vote down vote up
private static void fixUpTable() {
    if (patched) return;
    String[] patchup = {
            "CREATE TABLE HeartRate (_id INTEGER PRIMARY KEY AUTOINCREMENT);",
            "ALTER TABLE HeartRate ADD COLUMN timestamp INTEGER;",
            "ALTER TABLE HeartRate ADD COLUMN bpm INTEGER;",
            "ALTER TABLE HeartRate ADD COLUMN accuracy INTEGER;",
            "CREATE UNIQUE INDEX index_HeartRate_timestamp on HeartRate(timestamp);"};

    for (String patch : patchup) {
        try {
            SQLiteUtils.execSql(patch);
            //  UserError.Log.e(TAG, "Processed patch should not have succeeded!!: " + patch);
        } catch (Exception e) {
            //  UserError.Log.d(TAG, "Patch: " + patch + " generated exception as it should: " + e.toString());
        }
    }
    patched = true;
}
 
Example #13
Source File: DatabaseHelper.java    From clear-todolist with GNU General Public License v3.0 6 votes vote down vote up
private void executeCreateIndex(SQLiteDatabase db) {
	db.beginTransaction();
	try {
		for (TableInfo tableInfo : Cache.getTableInfos()) {
			String[] definitions = SQLiteUtils.createIndexDefinition(tableInfo);

			for (String definition : definitions) {
				db.execSQL(definition);
			}
		}
		db.setTransactionSuccessful();
	}
	finally {
		db.endTransaction();
	}
}
 
Example #14
Source File: Treatments.java    From xDrip with GNU General Public License v3.0 6 votes vote down vote up
private static void fixUpTable() {
    if (patched) return;
    String[] patchup = {
            "CREATE TABLE Treatments (_id INTEGER PRIMARY KEY AUTOINCREMENT);",
            "ALTER TABLE Treatments ADD COLUMN timestamp INTEGER;",
            "ALTER TABLE Treatments ADD COLUMN uuid TEXT;",
            "ALTER TABLE Treatments ADD COLUMN eventType TEXT;",
            "ALTER TABLE Treatments ADD COLUMN enteredBy TEXT;",
            "ALTER TABLE Treatments ADD COLUMN notes TEXT;",
            "ALTER TABLE Treatments ADD COLUMN created_at TEXT;",
            "ALTER TABLE Treatments ADD COLUMN insulin REAL;",
            "ALTER TABLE Treatments ADD COLUMN insulinJSON TEXT;",
            "ALTER TABLE Treatments ADD COLUMN carbs REAL;",
            "CREATE INDEX index_Treatments_timestamp on Treatments(timestamp);",
            "CREATE UNIQUE INDEX index_Treatments_uuid on Treatments(uuid);"};

    for (String patch : patchup) {
        try {
            SQLiteUtils.execSql(patch);
            //Log.e(TAG, "Processed patch should not have succeeded!!: " + patch);
        } catch (Exception e) {
            // Log.d(TAG, "Patch: " + patch + " generated exception as it should: " + e.toString());
        }
    }
    patched = true;
}
 
Example #15
Source File: BloodTest.java    From xDrip with GNU General Public License v3.0 6 votes vote down vote up
private static void fixUpTable() {
    if (patched) return;
    final String[] patchup = {
            "CREATE TABLE BloodTest (_id INTEGER PRIMARY KEY AUTOINCREMENT);",
            "ALTER TABLE BloodTest ADD COLUMN timestamp INTEGER;",
            "ALTER TABLE BloodTest ADD COLUMN created_timestamp INTEGER;",
            "ALTER TABLE BloodTest ADD COLUMN state INTEGER;",
            "ALTER TABLE BloodTest ADD COLUMN mgdl REAL;",
            "ALTER TABLE BloodTest ADD COLUMN source TEXT;",
            "ALTER TABLE BloodTest ADD COLUMN uuid TEXT;",
            "CREATE UNIQUE INDEX index_Bloodtest_uuid on BloodTest(uuid);",
            "CREATE UNIQUE INDEX index_Bloodtest_timestamp on BloodTest(timestamp);",
            "CREATE INDEX index_Bloodtest_created_timestamp on BloodTest(created_timestamp);",
            "CREATE INDEX index_Bloodtest_state on BloodTest(state);"};

    for (String patch : patchup) {
        try {
            SQLiteUtils.execSql(patch);
            //  UserError.Log.e(TAG, "Processed patch should not have succeeded!!: " + patch);
        } catch (Exception e) {
            //  UserError.Log.d(TAG, "Patch: " + patch + " generated exception as it should: " + e.toString());
        }
    }
    patched = true;
}
 
Example #16
Source File: BloodTest.java    From xDrip with GNU General Public License v3.0 6 votes vote down vote up
private static void fixUpTable() {
    if (patched) return;
    final String[] patchup = {
            "CREATE TABLE BloodTest (_id INTEGER PRIMARY KEY AUTOINCREMENT);",
            "ALTER TABLE BloodTest ADD COLUMN timestamp INTEGER;",
            "ALTER TABLE BloodTest ADD COLUMN created_timestamp INTEGER;",
            "ALTER TABLE BloodTest ADD COLUMN state INTEGER;",
            "ALTER TABLE BloodTest ADD COLUMN mgdl REAL;",
            "ALTER TABLE BloodTest ADD COLUMN source TEXT;",
            "ALTER TABLE BloodTest ADD COLUMN uuid TEXT;",
            "CREATE UNIQUE INDEX index_Bloodtest_uuid on BloodTest(uuid);",
            "CREATE UNIQUE INDEX index_Bloodtest_timestamp on BloodTest(timestamp);",
            "CREATE INDEX index_Bloodtest_created_timestamp on BloodTest(created_timestamp);",
            "CREATE INDEX index_Bloodtest_state on BloodTest(state);"};

    for (String patch : patchup) {
        try {
            SQLiteUtils.execSql(patch);
            //  UserError.Log.e(TAG, "Processed patch should not have succeeded!!: " + patch);
        } catch (Exception e) {
            //  UserError.Log.d(TAG, "Patch: " + patch + " generated exception as it should: " + e.toString());
        }
    }
    patched = true;
}
 
Example #17
Source File: PebbleMovement.java    From xDrip with GNU General Public License v3.0 6 votes vote down vote up
private static void fixUpTable() {
    if (patched) return;
    String[] patchup = {
            "CREATE TABLE PebbleMovement (_id INTEGER PRIMARY KEY AUTOINCREMENT);",
            "ALTER TABLE PebbleMovement ADD COLUMN timestamp INTEGER;",
            "ALTER TABLE PebbleMovement ADD COLUMN metric INTEGER;",
            "CREATE UNIQUE INDEX index_PebbleMovement_timestamp on PebbleMovement(timestamp);"};

    for (String patch : patchup) {
        try {
            SQLiteUtils.execSql(patch);
            //  UserError.Log.e(TAG, "Processed patch should not have succeeded!!: " + patch);
        } catch (Exception e) {
            //  UserError.Log.d(TAG, "Patch: " + patch + " generated exception as it should: " + e.toString());
        }
    }
    patched = true;
}
 
Example #18
Source File: DatabaseHelper.java    From mobile-android-survey-app with MIT License 6 votes vote down vote up
private void executeCreateIndex(SQLiteDatabase db) {
	db.beginTransaction();
	try {
		for (TableInfo tableInfo : Cache.getTableInfos()) {
			String[] definitions = SQLiteUtils.createIndexDefinition(tableInfo);

			for (String definition : definitions) {
				db.execSQL(definition);
			}
		}
		db.setTransactionSuccessful();
	}
	finally {
		db.endTransaction();
	}
}
 
Example #19
Source File: HeartRate.java    From xDrip with GNU General Public License v3.0 6 votes vote down vote up
private static void fixUpTable() {
    if (patched) return;
    String[] patchup = {
            "CREATE TABLE HeartRate (_id INTEGER PRIMARY KEY AUTOINCREMENT);",
            "ALTER TABLE HeartRate ADD COLUMN timestamp INTEGER;",
            "ALTER TABLE HeartRate ADD COLUMN bpm INTEGER;",
            "ALTER TABLE HeartRate ADD COLUMN accuracy INTEGER;",
            "CREATE UNIQUE INDEX index_HeartRate_timestamp on HeartRate(timestamp);"};

    for (String patch : patchup) {
        try {
            SQLiteUtils.execSql(patch);
            //  UserError.Log.e(TAG, "Processed patch should not have succeeded!!: " + patch);
        } catch (Exception e) {
            //  UserError.Log.d(TAG, "Patch: " + patch + " generated exception as it should: " + e.toString());
        }
    }
    patched = true;
}
 
Example #20
Source File: BgReading.java    From xDrip with GNU General Public License v3.0 6 votes vote down vote up
public synchronized static void updateDB() {
    final String[] updates = new String[]{"ALTER TABLE BgReadings ADD COLUMN dg_mgdl REAL;",
            "ALTER TABLE BgReadings ADD COLUMN dg_slope REAL;",
            "ALTER TABLE BgReadings ADD COLUMN dg_delta_name TEXT;",
            "ALTER TABLE BgReadings ADD COLUMN source_info TEXT;"};
    for (String patch : updates) {
        try {
            SQLiteUtils.execSql(patch);
        } catch (Exception e) {
        }
    }

    // needs different handling on wear
    if (JoH.areWeRunningOnAndroidWear()) {
        BgSendQueue.emptyQueue();
        SqliteRejigger.rejigSchema("BgReadings", "uuid TEXT UNIQUE ON CONFLICT FAIL", "uuid TEXT UNIQUE ON CONFLICT REPLACE");
        SqliteRejigger.rejigSchema("BgReadings", "uuid TEXT UNIQUE ON CONFLICT IGNORE", "uuid TEXT UNIQUE ON CONFLICT REPLACE");
        SqliteRejigger.rejigSchema("BgSendQueue", "BgReadings_temp", "BgReadings");
    }

}
 
Example #21
Source File: DatabaseHelper.java    From mobile-android-survey-app with MIT License 5 votes vote down vote up
private void executeCreate(SQLiteDatabase db) {
	db.beginTransaction();
	try {
		for (TableInfo tableInfo : Cache.getTableInfos()) {
			db.execSQL(SQLiteUtils.createTableDefinition(tableInfo));
		}
		db.setTransactionSuccessful();
	}
	finally {
		db.endTransaction();
	}
}
 
Example #22
Source File: PlusModel.java    From xDrip-plus with GNU General Public License v3.0 5 votes vote down vote up
protected synchronized static boolean fixUpTable(String[] schema, boolean patched) {
    if (patched) return true;

    for (String patch : schema) {
        try {
            SQLiteUtils.execSql(patch);
        } catch (Exception e) {
            //
        }
    }
    return true;
}
 
Example #23
Source File: From.java    From mobile-android-survey-app with MIT License 5 votes vote down vote up
public <T extends Model> T executeSingle() {
	if (mQueryBase instanceof Select) {
		limit(1);
		return (T) SQLiteUtils.rawQuerySingle(mType, toSql(), getArguments());
		
	} else {
		limit(1);
		SQLiteUtils.rawQuerySingle(mType, toSql(), getArguments()).delete();
		return null;
		
	}
}
 
Example #24
Source File: From.java    From mobile-android-survey-app with MIT License 5 votes vote down vote up
public <T extends Model> List<T> execute() {
	if (mQueryBase instanceof Select) {
		return SQLiteUtils.rawQuery(mType, toSql(), getArguments());
		
	} else {
		SQLiteUtils.execSql(toSql(), getArguments());
		Cache.getContext().getContentResolver().notifyChange(ContentProvider.createUri(mType, null), null);
		return null;
		
	}
}
 
Example #25
Source File: DatabaseHelper.java    From clear-todolist with GNU General Public License v3.0 5 votes vote down vote up
private void executeCreate(SQLiteDatabase db) {
	db.beginTransaction();
	try {
		for (TableInfo tableInfo : Cache.getTableInfos()) {
			db.execSQL(SQLiteUtils.createTableDefinition(tableInfo));
		}
		db.setTransactionSuccessful();
	}
	finally {
		db.endTransaction();
	}
}
 
Example #26
Source File: BgReading.java    From xDrip-plus with GNU General Public License v3.0 5 votes vote down vote up
public static void deleteALL() {
    try {
        SQLiteUtils.execSql("delete from BgSendQueue");
        SQLiteUtils.execSql("delete from BgReadings");
        Log.d(TAG, "Deleting all BGReadings");
    } catch (Exception e) {
        Log.e(TAG, "Got exception running deleteALL " + e.toString());
    }
}
 
Example #27
Source File: BgReading.java    From xDrip-plus with GNU General Public License v3.0 5 votes vote down vote up
public static void cleanup(long timestamp) {
    try {
        SQLiteUtils.execSql("delete from BgSendQueue");
        List<BgReading> data = new Select()
                .from(BgReading.class)
                .where("timestamp < ?", timestamp)
                .orderBy("timestamp desc")
                .execute();
        if (data != null) Log.d(TAG, "cleanup BgReading size=" + data.size());
        new Cleanup().execute(data);
    } catch (Exception e) {
        Log.e(TAG, "Got exception running cleanup " + e.toString());
    }
}
 
Example #28
Source File: UploaderQueue.java    From xDrip-plus with GNU General Public License v3.0 5 votes vote down vote up
private static void fixUpTable() {
    if (patched) return;

    for (String patch : schema) {
        try {
            SQLiteUtils.execSql(patch);
        } catch (Exception e) {
            if (d)
                UserError.Log.d(TAG, "Patch: " + patch + " generated exception as it should: " + e.toString());
        }
    }
    patched = true;
}
 
Example #29
Source File: From.java    From clear-todolist with GNU General Public License v3.0 5 votes vote down vote up
public <T extends Model> List<T> execute() {
	if (mQueryBase instanceof Select) {
		return SQLiteUtils.rawQuery(mType, toSql(), getArguments());
		
	} else {
		SQLiteUtils.execSql(toSql(), getArguments());
		Cache.getContext().getContentResolver().notifyChange(ContentProvider.createUri(mType, null), null);
		return null;
		
	}
}
 
Example #30
Source File: BgReading.java    From xDrip-plus with GNU General Public License v3.0 5 votes vote down vote up
public static void deleteALL() {
    try {
        SQLiteUtils.execSql("delete from BgSendQueue");
        SQLiteUtils.execSql("delete from BgReadings");
        Log.d(TAG, "Deleting all BGReadings");
    } catch (Exception e) {
        Log.e(TAG, "Got exception running deleteALL " + e.toString());
    }
}