use of android.database.Cursor in project platform_frameworks_base by android.
the class DatabaseStatementTest method testExecuteStatement.
@MediumTest
public void testExecuteStatement() throws Exception {
populateDefaultTable();
SQLiteStatement statement = mDatabase.compileStatement("DELETE FROM test");
statement.execute();
Cursor c = mDatabase.query("test", null, null, null, null, null, null);
assertEquals(0, c.getCount());
c.deactivate();
statement.close();
}
use of android.database.Cursor in project platform_frameworks_base by android.
the class DatabaseStatementTest method testStatementStringBinding.
@MediumTest
public void testStatementStringBinding() throws Exception {
mDatabase.execSQL("CREATE TABLE test (num TEXT);");
SQLiteStatement statement = mDatabase.compileStatement("INSERT INTO test (num) VALUES (?)");
for (long i = 0; i < 10; i++) {
statement.bindString(1, Long.toHexString(i));
statement.execute();
}
statement.close();
Cursor c = mDatabase.query("test", null, null, null, null, null, null);
int numCol = c.getColumnIndexOrThrow("num");
c.moveToFirst();
for (long i = 0; i < 10; i++) {
String num = c.getString(numCol);
assertEquals(Long.toHexString(i), num);
c.moveToNext();
}
c.close();
}
use of android.database.Cursor in project platform_frameworks_base by android.
the class DatabaseStatementTest method testStatementClearBindings.
@MediumTest
public void testStatementClearBindings() throws Exception {
mDatabase.execSQL("CREATE TABLE test (num INTEGER);");
SQLiteStatement statement = mDatabase.compileStatement("INSERT INTO test (num) VALUES (?)");
for (long i = 0; i < 10; i++) {
statement.bindLong(1, i);
statement.clearBindings();
statement.execute();
}
statement.close();
Cursor c = mDatabase.query("test", null, null, null, null, null, "ROWID");
int numCol = c.getColumnIndexOrThrow("num");
assertTrue(c.moveToFirst());
for (long i = 0; i < 10; i++) {
assertTrue(c.isNull(numCol));
c.moveToNext();
}
c.close();
}
use of android.database.Cursor in project platform_frameworks_base by android.
the class SimpleCursorAdapterTest method testChangeCursorLive.
/**
* Test changeCursor() with live cursor
*/
@SmallTest
public void testChangeCursorLive() {
SimpleCursorAdapter ca = new SimpleCursorAdapter(mContext, mLayout, mCursor2x2, mFrom, mTo);
// Now see if we can pull 2 rows from the adapter
assertEquals(2, ca.getCount());
// now put in a different cursor (5 rows)
ArrayList<ArrayList> data2 = createTestList(5, 2);
Cursor c2 = createCursor(mFrom, data2);
ca.changeCursor(c2);
// Now see if we can pull 5 rows from the adapter
assertEquals(5, ca.getCount());
}
use of android.database.Cursor in project platform_frameworks_base by android.
the class ListWithDisappearingItemBug method onCreate.
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
Toast.makeText(this, "Make sure you rotate screen to see bug", Toast.LENGTH_LONG).show();
// Get a cursor with all people
Cursor c = getContentResolver().query(People.CONTENT_URI, null, null, null, null);
startManagingCursor(c);
ListAdapter adapter = new SimpleCursorAdapter(this, // Use a template that displays a text view
R.layout.list_with_disappearing_item_bug_item, // Give the cursor to the list adatper
c, // Map the NAME column in the people database to...
new String[] { People.NAME }, // The "text1" view defined in the XML template
new int[] { R.id.text1 });
setListAdapter(adapter);
AnimationSet set = new AnimationSet(true);
Animation animation = new AlphaAnimation(0.0f, 1.0f);
animation.setDuration(50);
set.addAnimation(animation);
animation = new TranslateAnimation(Animation.RELATIVE_TO_SELF, 0.0f, Animation.RELATIVE_TO_SELF, 0.0f, Animation.RELATIVE_TO_SELF, -1.0f, Animation.RELATIVE_TO_SELF, 0.0f);
animation.setDuration(100);
set.addAnimation(animation);
LayoutAnimationController controller = new LayoutAnimationController(set, 0.5f);
ListView listView = getListView();
listView.setLayoutAnimation(controller);
}
Aggregations