use of android.database.sqlite.SQLiteCursor in project android_frameworks_base by ResurrectionRemix.
the class DatabaseCursorTest method testRequeryWithAlteredSelectionArgs.
@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();
}
use of android.database.sqlite.SQLiteCursor in project android_frameworks_base by DirtyUnicorns.
the class DatabaseCursorTest method testRequeryWithAlteredSelectionArgs.
@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();
}
use of android.database.sqlite.SQLiteCursor in project android_frameworks_base by ParanoidAndroid.
the class DatabaseCursorTest method testRequeryWithAlteredSelectionArgs.
@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();
}
use of android.database.sqlite.SQLiteCursor in project platform_frameworks_base by android.
the class DatabaseCursorTest method testRequeryWithAlteredSelectionArgs.
@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();
}
use of android.database.sqlite.SQLiteCursor in project android_frameworks_base by AOSPA.
the class DatabaseCursorTest method testRequeryWithAlteredSelectionArgs.
@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();
}
Aggregations