当前位置: 首页>>代码示例>>Java>>正文


Java SQLite类代码示例

本文整理汇总了Java中com.raizlabs.android.dbflow.sql.language.SQLite的典型用法代码示例。如果您正苦于以下问题:Java SQLite类的具体用法?Java SQLite怎么用?Java SQLite使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


SQLite类属于com.raizlabs.android.dbflow.sql.language包,在下文中一共展示了SQLite类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: load

import com.raizlabs.android.dbflow.sql.language.SQLite; //导入依赖的package包/类
@Override
public void load(SucceedCallback<List<Message>> callback) {
    super.load(callback);

    //(receiverId == receiverId and group_id == null) or (receiverId == receiver_Id)
    SQLite.select()
            .from(Message.class)
            .where(OperatorGroup.clause()
                    .and(Message_Table.sender_id.eq(receiverId))
                    .and(Message_Table.group_id.isNull()))
            .or(Message_Table.receiver_id.eq(receiverId))
            .orderBy(Message_Table.createAt,false)
            .limit(30)
            .async()
            .queryListResultCallback(this)
            .execute();
}
 
开发者ID:FZZFVII,项目名称:pipe,代码行数:18,代码来源:MessageRepository.java

示例2: updateGroup

import com.raizlabs.android.dbflow.sql.language.SQLite; //导入依赖的package包/类
/**
 * 从成员中找出成员对应的群,并对群进行更新
 *
 * @param members 群成员列表
 */
private void updateGroup(GroupMember... members) {
    // 不重复集合
    final Set<String> groupIds = new HashSet<>();
    for (GroupMember member : members) {
        // 添加群Id
        groupIds.add(member.getGroup().getId());
    }

    // 异步的数据库查询,并异步的发起二次通知
    DatabaseDefinition definition = FlowManager.getDatabase(AppDatabase.class);
    definition.beginTransactionAsync(new ITransaction() {
        @Override
        public void execute(DatabaseWrapper databaseWrapper) {
            // 找到需要通知的群
            List<Group> groups = SQLite.select()
                    .from(Group.class)
                    .where(Group_Table.id.in(groupIds))
                    .queryList();

            // 调用直接进行一次通知分发
            instance.notifySave(Group.class, groups.toArray(new Group[0]));

        }
    }).build().execute();
}
 
开发者ID:FZZFVII,项目名称:pipe,代码行数:31,代码来源:DbHelper.java

示例3: save

import com.raizlabs.android.dbflow.sql.language.SQLite; //导入依赖的package包/类
@Override
public Completable save(List<Recipe> recipes) {
    return Completable.defer(() -> {
        SQLite.delete(DBFlowRecipe.class).execute();
        SQLite.delete(DBFlowIngredient.class).execute();
        SQLite.delete(DBFlowStep.class).execute();
        FastStoreModelTransaction
                .insertBuilder(FlowManager.getModelAdapter(DBFlowRecipe.class))
                .addAll(DBFlowRecipe.Mapper.fromDomain(recipes))
                .build()
                .execute(database);
        for (Recipe recipe : recipes) {
            FastStoreModelTransaction
                    .insertBuilder(FlowManager.getModelAdapter(DBFlowIngredient.class))
                    .addAll(DBFlowIngredient.Mapper.fromDomain(recipe.ingredients(), recipe.id()))
                    .build()
                    .execute(database);
            FastStoreModelTransaction
                    .insertBuilder(FlowManager.getModelAdapter(DBFlowStep.class))
                    .addAll(DBFlowStep.Mapper.fromDomain(recipe.steps(), recipe.id()))
                    .build()
                    .execute(database);
        }
        return Completable.complete();
    });
}
 
开发者ID:ecarrara-araujo,项目名称:yabaking,代码行数:27,代码来源:DBFlowLocalDataSource.java

示例4: onCreate

import com.raizlabs.android.dbflow.sql.language.SQLite; //导入依赖的package包/类
@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_my_photos);

    // Query all Photos
    List<MyPhoto> myPhotos = SQLite.select().from(MyPhoto.class).queryList();

    // set up the RecyclerView
    RecyclerView recyclerView = (RecyclerView) findViewById(R.id.rvPhotos);
    int numberOfColumns = 3;
    recyclerView.setLayoutManager(new GridLayoutManager(this, numberOfColumns));
    adapter = new MyRecyclerViewAdapter(myPhotos);
    adapter.setClickListener(this);
    recyclerView.setAdapter(adapter);
}
 
开发者ID:micromasterandroid,项目名称:androidadvanced,代码行数:17,代码来源:MyPhotosActivity.java

示例5: saveAndReloadMessage

import com.raizlabs.android.dbflow.sql.language.SQLite; //导入依赖的package包/类
@Test
public void saveAndReloadMessage() throws Exception {
    byte[] payload = "This is another test message".getBytes();
    UnknownMessage message = UnknownMessage.createAndSignAsync(payload, TEST_ZERO_BITS).blockingGet();
    byte[] savedMessage = message.writeToByteArray();

    assertTrue(message.delete().blockingGet());

    assertEquals(0, SQLite.select().from(UnknownMessage.class).count());
    assertEquals(0, SQLite.select().from(BloomFilter.class).count());

    ByteArrayInputStream messageStream = new ByteArrayInputStream(savedMessage);
    UnknownMessage reloadedMessage = UnknownMessage.createFromSourceAsync(Okio.buffer(Okio.source(messageStream))).blockingGet();
    BitSet messageVector = BloomFilter.getMessageVectorAsync().blockingGet();

    assertTrue(reloadedMessage.isValid());
    assertPayloadContents(reloadedMessage, payload);
    assertVectorContainsMessage(reloadedMessage, messageVector);
}
 
开发者ID:aarmea,项目名称:noise,代码行数:20,代码来源:UnknownMessageTest.java

示例6: loadDecks

import com.raizlabs.android.dbflow.sql.language.SQLite; //导入依赖的package包/类
protected void loadDecks() {
    SQLite.select()
            .from(Deck.class)
            .async()
            .queryResultCallback(new QueryTransaction.QueryResultCallback<Deck>() {
                @Override
                public void onQueryResult(QueryTransaction transaction, @NonNull CursorResult<Deck> tResult) {
                    // called when query returns on UI thread
                    List<Deck> decks = tResult.toListClose();
                    if (decks != null && !decks.isEmpty()) {
                        deckListAdapter.setDeckList(decks);
                    } else {
                        loadExampleDecksFromFile();
                    }
                }
            }).execute();
}
 
开发者ID:unparalleled,项目名称:kcards,代码行数:18,代码来源:DeckListActivity.java

示例7: deleteAndInsertEntities

import com.raizlabs.android.dbflow.sql.language.SQLite; //导入依赖的package包/类
@CheckResult
@NonNull
@Override
public Single<List<D>> deleteAndInsertEntities(@Nullable List<D> entitiesToInsert,
                                               @NonNull SQLOperator... conditionsToDelete) {
  return Single
      .fromCallable(() -> {
        FlowManager.getDatabase(getAppDataBaseClass())
            .executeTransaction(databaseWrapper -> {
              SQLite.delete(getModelClass())
                  .where(conditionsToDelete)
                  .execute();
              Stream.ofNullable(entitiesToInsert)
                  .forEach(BaseModel::save);
            });
        return entitiesToInsert;
      })
      .subscribeOn(Schedulers.io());
}
 
开发者ID:xmartlabs,项目名称:bigbang,代码行数:20,代码来源:DbFlowController.java

示例8: getStocks

import com.raizlabs.android.dbflow.sql.language.SQLite; //导入依赖的package包/类
public Observable<Stocks> getStocks() {
    return Observable.defer(new Func0<Observable<Stocks>>() {
        @Override
        public Observable<Stocks> call() {

            List<Quote> quotes = SQLite.select()
                    .from(Quote.class)
                    .queryList();

            Stocks stock = new Stocks();
            stock.getQuery().getResult().setQuote(quotes);

            return Observable.just(stock);
        }
    });
}
 
开发者ID:therajanmaurya,项目名称:Stock-Hawk,代码行数:17,代码来源:DatabaseHelper.java

示例9: save

import com.raizlabs.android.dbflow.sql.language.SQLite; //导入依赖的package包/类
@Override
public void save() {
    super.save();

    long count = SQLite.selectCountOf().from(ItemCache.class).count();
    if (count > MAX_ITEMS) {
        SQLite.delete()
                .from(ItemCache.class)
                .where(ItemCache_Table.id.in(
                        SQLite.select(ItemCache_Table.id)
                                .from(ItemCache.class)
                                .orderBy(ItemCache_Table.lastUpdate, true)
                                .limit((int) (count - MAX_ITEMS))
                ))
                .query();
    }
}
 
开发者ID:setiawanp,项目名称:sunny-reader,代码行数:18,代码来源:ItemCache.java

示例10: prune

import com.raizlabs.android.dbflow.sql.language.SQLite; //导入依赖的package包/类
/** Prunes old submitted {@link Scrobble}s from the database, limiting to {@code MAX_ROWS}. */
public void prune() {
  long rowCount =
      SQLite.selectCountOf()
          .from(ScrobbleLogEntry.class)
          .where(ScrobbleLogEntry_Table.status.lessThan(0))
          .count();
  long toRemove = MAX_ROWS - rowCount;

  if (toRemove > 0) {
    SQLite.delete(ScrobbleLogEntry_Table.class)
        .where(ScrobbleLogEntry_Table.status.lessThan(0))
        .orderBy(ScrobbleLogEntry_Table.id, true)
        .limit((int) toRemove)
        .async()
        .execute();
  }
}
 
开发者ID:peterjosling,项目名称:scroball,代码行数:19,代码来源:ScroballDB.java

示例11: getFavouriteWorkflow

import com.raizlabs.android.dbflow.sql.language.SQLite; //导入依赖的package包/类
public Observable<Boolean> getFavouriteWorkflow(final String id) {
    return Observable.create(new Observable.OnSubscribe<Boolean>() {
        @Override
        public void call(Subscriber<? super Boolean> subscriber) {
            if (subscriber.isUnsubscribed()) return;
            Workflow workflow1 = SQLite.select()
                    .from(Workflow.class)
                    .where(Workflow_Table.id.eq(id))
                    .querySingle();

            if (workflow1 != null) {

                subscriber.onNext(workflow1.isFavourite());
                subscriber.onCompleted();
            } else {

                subscriber.onError(null);
            }


        }
    });
}
 
开发者ID:apache,项目名称:incubator-taverna-mobile,代码行数:24,代码来源:DBHelper.java

示例12: update

import com.raizlabs.android.dbflow.sql.language.SQLite; //导入依赖的package包/类
public void update() {
    courses.clear();

    // Get all of the courses from the DB
    SQLite.select()
            .from(TranscriptCourse.class)
            .where(TranscriptCourse_Table.semesterId.eq(semesterId))
            .async()
            .queryListResultCallback((transaction, tResult) -> {
                if (tResult == null) {
                    return;
                }
                courses.addAll(tResult);
                notifyDataSetChanged();
            })
            .execute();
}
 
开发者ID:jguerinet,项目名称:MyMartlet,代码行数:18,代码来源:SemesterAdapter.java

示例13: update

import com.raizlabs.android.dbflow.sql.language.SQLite; //导入依赖的package包/类
public void update(Term term, boolean canUnregister) {
    this.canUnregister = canUnregister;
    courses.clear();
    checkedCourses.clear();

    // Get the courses asynchronously
    SQLite.select()
            .from(Course.class)
            .where(Course_Table.term.eq(term))
            .async()
            .queryListResultCallback((transaction, tResult) -> {
                if (tResult == null) {
                    tResult = new ArrayList<>();
                }
                courses.addAll(tResult);
                showEmptyView(courses.isEmpty());
                notifyDataSetChanged();
            })
            .execute();
}
 
开发者ID:jguerinet,项目名称:MyMartlet,代码行数:21,代码来源:CoursesAdapter.java

示例14: update

import com.raizlabs.android.dbflow.sql.language.SQLite; //导入依赖的package包/类
/**
 * Updates the list of {@link Statement}s shown
 */
void update() {
    // Clear existing statements
    mStatements.clear();

    // Add the other statements asynchronously
    SQLite
            .select()
            .from(Statement.class)
            .async()
            .queryListResultCallback((transaction, tResult) -> {
                if (tResult == null) {
                    return;
                }
                mStatements.addAll(tResult);
                notifyDataSetChanged();
            })
            .execute();
}
 
开发者ID:jguerinet,项目名称:MyMartlet,代码行数:22,代码来源:EbillAdapter.java

示例15: refresh

import com.raizlabs.android.dbflow.sql.language.SQLite; //导入依赖的package包/类
/**
 * Refreshes the course info on the current wishlist
 */
private void refresh() {
    showToolbarProgress(true);

    // Go through the user's wishlist
    SQLite.select()
            .from(CourseResult.class)
            .async()
            .queryListResultCallback((transaction, tResult) -> {
                if (tResult == null) {
                    tResult = new ArrayList<>();
                }
                List<CourseHolder> holders = new ArrayList<>();
                for (CourseResult course : tResult) {
                    CourseHolder holder = new CourseHolder(course);
                    if (!holders.contains(holder)) {
                        holders.add(holder);
                    }
                }
                mainHandler.post(() -> performUpdateCalls(holders));
            })
            .execute();

}
 
开发者ID:jguerinet,项目名称:MyMartlet,代码行数:27,代码来源:WishlistActivity.java


注:本文中的com.raizlabs.android.dbflow.sql.language.SQLite类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。