Пример #1
0
 public Completable addUnsentLocationRecord(LocationRecord locationRecord) {
   return Completable.create(
       subscribe -> {
         BriteDatabase.Transaction transaction = mBriteDatabase.newTransaction();
         try {
           mBriteDatabase.insert(
               LocalUnsentLocationRecordTable.NAME,
               LocalUnsentLocationRecordTable.toContentValues(locationRecord));
           transaction.markSuccessful();
           subscribe.onCompleted();
         } finally {
           transaction.end();
         }
       });
 }
Пример #2
0
 public Completable clearTables() {
   return Completable.create(
       subscribe -> {
         BriteDatabase.Transaction transaction = mBriteDatabase.newTransaction();
         try {
           Cursor cursor =
               mBriteDatabase.query("SELECT name FROM sqlite_master WHERE type='table'");
           while (cursor.moveToNext()) {
             mBriteDatabase.delete(cursor.getString(cursor.getColumnIndex("name")), null);
           }
           cursor.close();
           transaction.markSuccessful();
           subscribe.onCompleted();
         } finally {
           transaction.end();
         }
       });
 }