org.greenrobot.greendao.database.Database.getRawDatabase()方法的使用及代码示例

x33g5p2x  于2022-01-18 转载在 其他  
字(6.6k)|赞(0)|评价(0)|浏览(208)

本文整理了Java中org.greenrobot.greendao.database.Database.getRawDatabase()方法的一些代码示例,展示了Database.getRawDatabase()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Database.getRawDatabase()方法的具体详情如下:
包路径:org.greenrobot.greendao.database.Database
类名称:Database
方法名:getRawDatabase

Database.getRawDatabase介绍

暂无

代码示例

代码示例来源:origin: greenrobot/greenDAO

  1. @SuppressWarnings("unchecked")
  2. public AbstractDao(DaoConfig config, AbstractDaoSession daoSession) {
  3. this.config = config;
  4. this.session = daoSession;
  5. db = config.db;
  6. isStandardSQLite = db.getRawDatabase() instanceof SQLiteDatabase;
  7. identityScope = (IdentityScope<K, T>) config.getIdentityScope();
  8. if (identityScope instanceof IdentityScopeLong) {
  9. identityScopeLong = (IdentityScopeLong<T>) identityScope;
  10. } else {
  11. identityScopeLong = null;
  12. }
  13. statements = config.statements;
  14. pkOrdinal = config.pkProperty != null ? config.pkProperty.ordinal : -1;
  15. }

代码示例来源:origin: greenrobot/greenDAO

  1. /**
  2. * If using Android's embedded SQLite, this enables localized ordering of strings
  3. * (see {@link #orderAsc(Property...)} and {@link #orderDesc(Property...)}). This uses "COLLATE LOCALIZED", which
  4. * is unavailable in SQLCipher (in that case, the ordering is unchanged).
  5. *
  6. * @see #stringOrderCollation
  7. */
  8. public QueryBuilder<T> preferLocalizedStringOrder() {
  9. // SQLCipher 3.5.0+ does not understand "COLLATE LOCALIZED"
  10. if (dao.getDatabase().getRawDatabase() instanceof SQLiteDatabase) {
  11. stringOrderCollation = " COLLATE LOCALIZED";
  12. }
  13. return this;
  14. }

代码示例来源:origin: greenrobot/greenDAO

  1. @Test
  2. public void testMockitoMocks() {
  3. mock(DaoMaster.class).newSession();
  4. mock(DaoSession.class).getDatabase();
  5. mock(Database.class).getRawDatabase();
  6. mock(DatabaseStatement.class).execute();
  7. mock(IdentityScope.class).clear();
  8. mock(AbstractDao.class).queryBuilder();
  9. mock(MinimalEntityDao.class).queryBuilder();
  10. mock(MinimalEntity.class).getId();
  11. mock(Query.class).forCurrentThread();
  12. mock(QueryBuilder.class).build();
  13. mock(CountQuery.class).forCurrentThread();
  14. mock(DeleteQuery.class).forCurrentThread();
  15. mock(Join.class).getTablePrefix();
  16. mock(LazyList.class).getLoadedCount();
  17. mock(WhereCondition.class).appendValuesTo(null);
  18. mock(Property.class).isNull();
  19. mock(DaoException.class).getMessage();
  20. }

代码示例来源:origin: greenrobot/greenDAO

  1. public void testConcurrentLockAndQueryDuringTxWAL() throws InterruptedException {
  2. if (Build.VERSION.SDK_INT >= 16) {
  3. try {
  4. Object rawDatabase = db.getRawDatabase();
  5. Method method = rawDatabase.getClass().getMethod("isWriteAheadLoggingEnabled");
  6. boolean walEnabled = (Boolean) method.invoke(rawDatabase);

代码示例来源:origin: org.greenrobot/greendao

  1. /**
  2. * If using Android's embedded SQLite, this enables localized ordering of strings
  3. * (see {@link #orderAsc(Property...)} and {@link #orderDesc(Property...)}). This uses "COLLATE LOCALIZED", which
  4. * is unavailable in SQLCipher (in that case, the ordering is unchanged).
  5. *
  6. * @see #stringOrderCollation
  7. */
  8. public QueryBuilder<T> preferLocalizedStringOrder() {
  9. // SQLCipher 3.5.0+ does not understand "COLLATE LOCALIZED"
  10. if (dao.getDatabase().getRawDatabase() instanceof SQLiteDatabase) {
  11. stringOrderCollation = " COLLATE LOCALIZED";
  12. }
  13. return this;
  14. }

代码示例来源:origin: org.greenrobot/greendao

  1. /**
  2. * Customizes the ordering of strings used by {@link #orderAsc(Property...)} and {@link #orderDesc(Property...)}.
  3. * Default is "COLLATE NOCASE".
  4. *
  5. * @see #preferLocalizedStringOrder
  6. */
  7. public QueryBuilder<T> stringOrderCollation(String stringOrderCollation) {
  8. // SQLCipher 3.5.0+ does not understand "COLLATE LOCALIZED"
  9. if (dao.getDatabase().getRawDatabase() instanceof SQLiteDatabase) {
  10. this.stringOrderCollation = stringOrderCollation == null || stringOrderCollation.startsWith(" ") ?
  11. stringOrderCollation : " " + stringOrderCollation;
  12. }
  13. return this;
  14. }

代码示例来源:origin: org.greenrobot/greendao

  1. @SuppressWarnings("unchecked")
  2. public AbstractDao(DaoConfig config, AbstractDaoSession daoSession) {
  3. this.config = config;
  4. this.session = daoSession;
  5. db = config.db;
  6. isStandardSQLite = db.getRawDatabase() instanceof SQLiteDatabase;
  7. identityScope = (IdentityScope<K, T>) config.getIdentityScope();
  8. if (identityScope instanceof IdentityScopeLong) {
  9. identityScopeLong = (IdentityScopeLong<T>) identityScope;
  10. } else {
  11. identityScopeLong = null;
  12. }
  13. statements = config.statements;
  14. pkOrdinal = config.pkProperty != null ? config.pkProperty.ordinal : -1;
  15. }

代码示例来源:origin: wallabag/android-app

  1. public ArticlesChangedEvent update(UpdateType updateType, long latestUpdatedItemTimestamp,
  2. UpdateListener updateListener)
  3. throws UnsuccessfulResponseException, IOException {
  4. boolean clean = updateType != UpdateType.FAST;
  5. Log.i(TAG, "update() started; clean: " + clean);
  6. ArticlesChangedEvent event = new ArticlesChangedEvent();
  7. SQLiteDatabase sqliteDatabase = (SQLiteDatabase)daoSession.getDatabase().getRawDatabase();
  8. sqliteDatabase.beginTransactionNonExclusive();
  9. try {
  10. if(clean) {
  11. Log.d(TAG, "update() deleting old DB entries");
  12. daoSession.getArticleTagsJoinDao().deleteAll();
  13. daoSession.getArticleDao().deleteAll();
  14. daoSession.getTagDao().deleteAll();
  15. event.invalidateAll(ChangeType.DELETED);
  16. }
  17. Log.v(TAG, "update() latestUpdatedItemTimestamp: " + latestUpdatedItemTimestamp);
  18. Log.d(TAG, "update() updating articles");
  19. latestUpdatedItemTimestamp = performUpdate(
  20. event, clean, latestUpdatedItemTimestamp, updateListener);
  21. Log.d(TAG, "update() articles updated");
  22. Log.v(TAG, "update() latestUpdatedItemTimestamp: " + latestUpdatedItemTimestamp);
  23. sqliteDatabase.setTransactionSuccessful();
  24. } finally {
  25. sqliteDatabase.endTransaction();
  26. }
  27. if(updateListener != null) updateListener.onSuccess(latestUpdatedItemTimestamp);
  28. Log.i(TAG, "update() finished");
  29. return event;
  30. }

代码示例来源:origin: wallabag/android-app

  1. public static DaoSession getSession() {
  2. if(Holder.session == null) {
  3. // enable some debugging
  4. if(BuildConfig.DEBUG) {
  5. QueryBuilder.LOG_SQL = true;
  6. QueryBuilder.LOG_VALUES = true;
  7. }
  8. String dbPath = new Settings(context).getDbPathForDbHelper();
  9. Log.d(TAG, "creating new db session");
  10. WallabagOpenHelper dbHelper = new WallabagOpenHelper(context, dbPath, null);
  11. if(Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN) {
  12. dbHelper.setWriteAheadLoggingEnabled(true);
  13. }
  14. Database db = dbHelper.getWritableDb();
  15. if(Build.VERSION.SDK_INT < Build.VERSION_CODES.JELLY_BEAN) {
  16. if(!((SQLiteDatabase)db.getRawDatabase()).enableWriteAheadLogging()) {
  17. Log.w(TAG, "write ahead logging was not enabled");
  18. }
  19. }
  20. DaoMaster daoMaster = new DaoMaster(db);
  21. Holder.session = daoMaster.newSession();
  22. } else {
  23. Log.d(TAG, "using existing db session");
  24. }
  25. return Holder.session;
  26. }

代码示例来源:origin: wallabag/android-app

  1. SQLiteDatabase sqliteDatabase = (SQLiteDatabase)daoSession.getDatabase().getRawDatabase();
  2. sqliteDatabase.beginTransactionNonExclusive();
  3. try {

代码示例来源:origin: wallabag/android-app

  1. SQLiteDatabase sqliteDatabase = (SQLiteDatabase)daoSession.getDatabase().getRawDatabase();
  2. sqliteDatabase.beginTransactionNonExclusive();
  3. try {

相关文章