本文整理汇总了Java中com.activeandroid.util.SQLiteUtils类的典型用法代码示例。如果您正苦于以下问题:Java SQLiteUtils类的具体用法?Java SQLiteUtils怎么用?Java SQLiteUtils使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
SQLiteUtils类属于com.activeandroid.util包,在下文中一共展示了SQLiteUtils类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: executeCreateIndex
import com.activeandroid.util.SQLiteUtils; //导入依赖的package包/类
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();
}
}
示例2: fixUpTable
import com.activeandroid.util.SQLiteUtils; //导入依赖的package包/类
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;
}
示例3: fixUpTable
import com.activeandroid.util.SQLiteUtils; //导入依赖的package包/类
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;
}
示例4: fixUpTable
import com.activeandroid.util.SQLiteUtils; //导入依赖的package包/类
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;
}
示例5: fixUpTable
import com.activeandroid.util.SQLiteUtils; //导入依赖的package包/类
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 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;
}
示例6: execute
import com.activeandroid.util.SQLiteUtils; //导入依赖的package包/类
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;
}
}
示例7: executeSingle
import com.activeandroid.util.SQLiteUtils; //导入依赖的package包/类
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;
}
}
示例8: executeCreate
import com.activeandroid.util.SQLiteUtils; //导入依赖的package包/类
private void executeCreate(SQLiteDatabase db) {
db.beginTransaction();
try {
for (TableInfo tableInfo : Cache.getTableInfos()) {
db.execSQL(SQLiteUtils.createTableDefinition(tableInfo));
}
db.setTransactionSuccessful();
}
finally {
db.endTransaction();
}
}
示例9: cleanup
import com.activeandroid.util.SQLiteUtils; //导入依赖的package包/类
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());
}
}
示例10: fixUpTable
import com.activeandroid.util.SQLiteUtils; //导入依赖的package包/类
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;
}
示例11: fixUpTable
import com.activeandroid.util.SQLiteUtils; //导入依赖的package包/类
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;
}
示例12: fixUpTable
import com.activeandroid.util.SQLiteUtils; //导入依赖的package包/类
protected synchronized static void fixUpTable(String[] schema) {
if (patched) return;
for (String patch : schema) {
try {
SQLiteUtils.execSql(patch);
} catch (Exception e) {
//
}
}
patched = true;
}
示例13: updateDB
import com.activeandroid.util.SQLiteUtils; //导入依赖的package包/类
public static void updateDB(){
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;"};
for (String patch:updates) {
try {
SQLiteUtils.execSql(patch);
} catch (Exception e){
}
}
}
示例14: deleteALL
import com.activeandroid.util.SQLiteUtils; //导入依赖的package包/类
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());
}
}
示例15: cleanup
import com.activeandroid.util.SQLiteUtils; //导入依赖的package包/类
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());
}
}