Java Code Examples for com.activeandroid.util.SQLiteUtils

The following examples show how to use com.activeandroid.util.SQLiteUtils. These examples are extracted from open source projects. 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 Project: xDrip   Source File: BloodTest.java    License: 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 2
Source Project: xDrip   Source File: PebbleMovement.java    License: 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 3
Source Project: xDrip   Source File: HeartRate.java    License: 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 4
Source Project: xDrip   Source File: BgReading.java    License: 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 5
Source Project: xDrip   Source File: BloodTest.java    License: 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 6
Source Project: xDrip   Source File: Treatments.java    License: 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 7
Source Project: xDrip   Source File: HeartRate.java    License: 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 8
Source Project: xDrip   Source File: StepCounter.java    License: 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 Project: xDrip   Source File: BgReading.java    License: 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 10
Source Project: xDrip-plus   Source File: BloodTest.java    License: 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 11
Source Project: xDrip-plus   Source File: PebbleMovement.java    License: 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 12
Source Project: xDrip-plus   Source File: HeartRate.java    License: 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 Project: xDrip-plus   Source File: BgReading.java    License: 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 14
Source Project: xDrip-plus   Source File: BloodTest.java    License: 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 15
Source Project: xDrip-plus   Source File: Treatments.java    License: 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 16
Source Project: xDrip-plus   Source File: HeartRate.java    License: 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 17
Source Project: xDrip-plus   Source File: StepCounter.java    License: 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 Project: xDrip-plus   Source File: BgReading.java    License: 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 19
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 20
Source Project: mobile-android-survey-app   Source File: DatabaseHelper.java    License: 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 21
Source Project: xDrip   Source File: Calibration.java    License: GNU General Public License v3.0 5 votes vote down vote up
public static void cleanup(long timestamp) {
    try {
        SQLiteUtils.execSql("delete from CalibrationRequest");
        List<Calibration> data = new Select()
                .from(BgReading.class)
                .where("timestamp < ?", timestamp)
                .orderBy("timestamp desc")
                .execute();
        if (data != null) Log.d(TAG, "cleanup Calibration size=" + data.size());
        new Calibration.Cleanup().execute(data);
    } catch (Exception e) {
        Log.e(TAG, "Got exception running cleanup " + e.toString());
    }
}
 
Example 22
Source Project: xDrip   Source File: UserNotification.java    License: GNU General Public License v3.0 5 votes vote down vote up
public 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 23
Source Project: xDrip   Source File: Treatments.java    License: GNU General Public License v3.0 5 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 systimestamp 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 carbs REAL;",
            "CREATE INDEX index_Treatments_timestamp on Treatments(timestamp);",
            "CREATE INDEX index_Treatments_systimestamp on Treatments(systimestamp);",
            "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 24
Source Project: xDrip   Source File: PlusModel.java    License: 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 25
Source Project: xDrip   Source File: BgReading.java    License: 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 26
Source Project: xDrip   Source File: BgReading.java    License: 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 27
Source Project: xDrip   Source File: Reminder.java    License: GNU General Public License v3.0 5 votes vote down vote up
protected synchronized static void fixUpTable(String[] schema) {
    if (patched) return;
    for (String patch : schema) {
        try {
            SQLiteUtils.execSql(patch);
        } catch (Exception e) {
            //
        }
    }
    patched = true;
}
 
Example 28
Source Project: xDrip   Source File: PlusModel.java    License: 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 29
Source Project: xDrip   Source File: BgReading.java    License: 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 30
Source Project: xDrip   Source File: BgReading.java    License: 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());
    }
}