/** * {@inheritDoc} */ @Override public Cursor newCursor(SQLiteDatabase db, SQLiteCursorDriver driver, String editTable, SQLiteQuery query) { // Create a standard cursor Cursor cursor = new SQLiteCursor(driver, editTable, query); // Check if there is an edit table if (editTable != null) { // Check if the table has a cursor wrapper GeoPackageCursorWrapper cursorWrapper = tableCursors.get(editTable); if (cursorWrapper != null) { cursor = cursorWrapper.wrapCursor(cursor); } } return cursor; }
public SQLiteDatabase openDatabase(final File dbFile) { return SQLiteDatabase.openDatabase(dbFile.getAbsolutePath(), new SQLiteDatabase.CursorFactory() { @Override @SuppressWarnings("deprecation") public Cursor newCursor(final SQLiteDatabase db, SQLiteCursorDriver driver, String editTable, SQLiteQuery query) { return new SQLiteCursor(db, driver, editTable, query) { @Override public void close() { Log.d(TAG, "closing cursor"); super.close(); db.close(); if (!dbFile.delete()) { Log.w(TAG, "could not delete database " + dbFile); } } }; } }, SQLiteDatabase.OPEN_READWRITE); }
@Override public Cursor newCursor(SQLiteDatabase db, SQLiteCursorDriver masterQuery, String editTable, SQLiteQuery query) { Cursor cursor = CURSOR_FACTORY.newCursor(db, masterQuery, editTable, query); long start = System.currentTimeMillis(); cursor.getCount(); // to fill window long end = System.currentTimeMillis(); long elapsed = end - start; if (elapsed > mQueryTimeLimit) { // ugly hack warning, the next line depends on current SQLiteQuery implementation: String queryString = query.toString().substring("SQLiteQuery: ".length()); List<String> queryPlan = mQueryPlanGetter.getQueryPlan(db, queryString, editTable); dumpIssueReport(queryString, queryPlan, elapsed); } return cursor; }
@Override public final Cursor newCursor(final SQLiteDatabase pDb, final SQLiteCursorDriver pMasterQuery, final String pEditTable, final SQLiteQuery pQuery) { return new SQLiteCursor(pDb, pMasterQuery, pEditTable, pQuery) { @Override public boolean requery() { setSelectionArguments(new String[] {"2"}); return super.requery(); } }; }
@Override public Cursor newCursor(SQLiteDatabase db, SQLiteCursorDriver masterQuery, String editTable, SQLiteQuery query) { if (FSDBHelper.inst().inDebugMode()) { Log.d("forsuredb", "Running query: " + masterQuery.toString()); } return new FSCursor(new SQLiteCursor(masterQuery, editTable, query)); }
@Override public Cursor newCursor(SQLiteDatabase db, SQLiteCursorDriver masterQuery, String editTable, SQLiteQuery query) { /** * {@link SQLiteDatabase} and {@link android.database.sqlite.SQLiteDirectCursorDriver} */ return new AutoCloseCursor(new SQLiteCursor(masterQuery, editTable, query)); }
@Override public Cursor newCursor(SQLiteDatabase sqLiteDatabase, SQLiteCursorDriver sqLiteCursorDriver, String tableName, SQLiteQuery sqLiteQuery) { if (isDebugEnabled) { QuantumFluxLog.d(sqLiteQuery.toString()); } return new SQLiteCursor(sqLiteCursorDriver, tableName, sqLiteQuery); }
@Override public Cursor rawQuery(final SupportSQLiteQuery supportQuery) { return rawQueryWithFactory(new SQLiteDatabase.CursorFactory() { @Override public Cursor newCursor(SQLiteDatabase db, SQLiteCursorDriver masterQuery, String editTable, SQLiteQuery query) { supportQuery.bindTo(new FrameworkSQLiteProgram(query)); return new SQLiteCursor(masterQuery, editTable, query); } }, supportQuery.getSql(), EMPTY_STRING_ARRAY, null); }
@SuppressWarnings("deprecation") public Cursor newCursor(SQLiteDatabase sqLiteDatabase, SQLiteCursorDriver sqLiteCursorDriver, String editTable, SQLiteQuery sqLiteQuery) { if(Joogar.isDebug()) { Joogar.getInstance().getLogger().d(sqLiteQuery.toString()); } return new SQLiteCursor(sqLiteDatabase, sqLiteCursorDriver, editTable, sqLiteQuery); }
@Override public Cursor newCursor(SQLiteDatabase sqLiteDatabase, SQLiteCursorDriver sqLiteCursorDriver, String tableName, SQLiteQuery sqLiteQuery) { if (debugEnabled) { CPOrmLog.d(sqLiteQuery.toString()); } return new SQLiteCursor(sqLiteCursorDriver, tableName, sqLiteQuery); }
@SuppressWarnings("deprecation") public Cursor newCursor(SQLiteDatabase sqLiteDatabase, SQLiteCursorDriver sqLiteCursorDriver, String editTable, SQLiteQuery sqLiteQuery) { if (debugEnabled) { Log.d("SQL Log", sqLiteQuery.toString()); } return new SQLiteCursor(sqLiteDatabase, sqLiteCursorDriver, editTable, sqLiteQuery); }
@Override public Cursor newCursor(SQLiteDatabase db, SQLiteCursorDriver masterQuery, String editTable, SQLiteQuery query) { if (models == null || !models.containsKey(editTable)) { return new SQLiteCursor(db, masterQuery, editTable, query); } else { EncryptedModel model = models.get(editTable); return new DecryptingCursor(db, masterQuery, editTable, query, model, getCipherPool()); } }
@SuppressWarnings("deprecation") @Override public Cursor newCursor(SQLiteDatabase db, SQLiteCursorDriver masterQuery, String editTable, SQLiteQuery query) { LOG.debug(query.toString()); // non-deprecated API is only available in API 11 return new SQLiteCursor(db, masterQuery, editTable, query); }
@Override public Cursor newCursor(SQLiteDatabase db, SQLiteCursorDriver masterQuery, String editTable, SQLiteQuery query) { if (debugQueries) { Log.d("SQL", query.toString()); } return new SQLiteCursor(db, masterQuery, editTable, query); }
/** * Log the query of the given cursor. */ private void logCursor(Cursor cursor, String[] selectionArgs) { try { Field queryField = SQLiteCursor.class.getDeclaredField("mQuery"); queryField.setAccessible(true); SQLiteQuery sqliteQuery = (SQLiteQuery) queryField.get(cursor); Log.v(TAG, sqliteQuery.toString() + ": " + Arrays.toString(selectionArgs)); } catch (Exception e) { Log.v(TAG, e.getMessage(), e); } }
@Override public Cursor newCursor(SQLiteDatabase db, SQLiteCursorDriver masterQuery, String editTable, SQLiteQuery query) { if (debugQueries) { DUtils.log(query.toString()); } return new SQLiteCursor(masterQuery, editTable, query); }
public AsyncCursor(SQLiteDatabase db, SQLiteCursorDriver driver, String editTable, SQLiteQuery query) { super(db, driver, editTable, query); }
@Override public Cursor newCursor(SQLiteDatabase db, SQLiteCursorDriver driver, String editTable, SQLiteQuery query) { return new AsyncCursor(db, driver, editTable, query); }
@Override public Cursor newCursor(SQLiteDatabase db, SQLiteCursorDriver masterQuery, String editTable, SQLiteQuery query) { Cursor cursor = new SQLiteCursor(masterQuery, editTable, query); return new CustomCursor(cursor); }
public Cursor newCursor(SQLiteDatabase db, SQLiteCursorDriver masterQuery, String editTable, SQLiteQuery query) { return new ScraperCursor(masterQuery, editTable, query); }
public ScraperCursor(SQLiteCursorDriver driver, String editTable, SQLiteQuery query) { super(driver, editTable, query); }
static SQLiteQuery newQuery(SQLiteDatabase db, String sql) { return QUERY_IMPL.newInstance(db, sql); }
@MediumTest public void testRequeryWithAlteredSelectionArgs() throws Exception { /** * Test the ability of a subclass of SQLiteCursor to change its query arguments. */ populateDefaultTable(); SQLiteDatabase.CursorFactory factory = new SQLiteDatabase.CursorFactory() { public Cursor newCursor( SQLiteDatabase db, SQLiteCursorDriver masterQuery, String editTable, SQLiteQuery query) { return new SQLiteCursor(db, masterQuery, editTable, query) { @Override public boolean requery() { setSelectionArguments(new String[]{"2"}); return super.requery(); } }; } }; Cursor c = mDatabase.rawQueryWithFactory( factory, "SELECT data FROM test WHERE _id <= ?", new String[]{"1"}, null); assertNotNull(c); assertEquals(1, c.getCount()); assertTrue(c.moveToFirst()); assertEquals(sString1, c.getString(0)); // Our hacked requery() changes the query arguments in the cursor. c.requery(); assertEquals(2, c.getCount()); assertTrue(c.moveToFirst()); assertEquals(sString1, c.getString(0)); assertTrue(c.moveToNext()); assertEquals(sString2, c.getString(0)); // Test that setting query args on a deactivated cursor also works. c.deactivate(); c.requery(); }
@Override public Cursor newCursor(SQLiteDatabase db, SQLiteCursorDriver masterQuery, String editTable, SQLiteQuery query) { bindArgumentsToProgram(query, sqlArgs); return new SQLiteCursor(masterQuery, editTable, query); }
private DownloadsCursor(SQLiteDatabase db, SQLiteCursorDriver driver, String editTable, SQLiteQuery query) { super(db, driver, editTable, query); }
@Override public Cursor newCursor(SQLiteDatabase db, SQLiteCursorDriver driver, String editTable, SQLiteQuery query) { return new DownloadsCursor(db, driver, editTable, query); }
private FavoritesCursor(SQLiteDatabase db, SQLiteCursorDriver driver, String editTable, SQLiteQuery query) { super(db, driver, editTable, query); }
@Override public Cursor newCursor(SQLiteDatabase db, SQLiteCursorDriver driver, String editTable, SQLiteQuery query) { return new FavoritesCursor(db, driver, editTable, query); }
private DirectoriesCursor(SQLiteDatabase db, SQLiteCursorDriver driver, String editTable, SQLiteQuery query) { super(db, driver, editTable, query); }
private DirectoriesCursor(SQLiteCursorDriver driver, String editTable, SQLiteQuery query) { super(driver, editTable, query); }
@Override public Cursor newCursor(SQLiteDatabase db, SQLiteCursorDriver driver, String editTable, SQLiteQuery query) { return new DirectoriesCursor(db, driver, editTable, query); }
public DecryptingCursor(SQLiteDatabase db, SQLiteCursorDriver driver, String editTable, SQLiteQuery query, EncryptedModel model, CipherPool pool) { super(db, driver, editTable, query); this.model = model; this.pool = pool; this.cipher = pool.borrow(); }
public Cursor newCursor(SQLiteDatabase db, SQLiteCursorDriver driver, String editTable, SQLiteQuery query) { return new SQLiteCursor(db, driver, editTable, query); }
@Override public Cursor newCursor(SQLiteDatabase db, SQLiteCursorDriver driver, String editTable, SQLiteQuery query) { d("newCursor"); return new TestCursor(db, driver, editTable, query); }
public TestCursor(SQLiteDatabase db, SQLiteCursorDriver driver, String editTable, SQLiteQuery query) { super(driver, editTable, query); _db = db; }
@SuppressWarnings("deprecation") @Override public Cursor newCursor(SQLiteDatabase db, SQLiteCursorDriver masterQuery, String editTable, SQLiteQuery query) { return new SQLiteCursor(db, masterQuery, editTable, query); }