have an app with a ListView that displays data queried from the
ContentProvider. I run a query() on the ContentProvider, then I take
the returned Cursor, make an adaptor, and set it to the ListView, like
so:
dbAdapter = getContentResolver();
deviceList = (ListView)this.findViewById(R.id.deviceList);
Cursor allDevices =
dbAdapter.query(BluetoothContentProvider.CONTENT_URI,
BluetoothContentProvider.ALL_COLUMNS,
null,
null,
BluetoothContentProvider.KEY_ROWID + " ASC");
startManagingCursor(allDevices);
SimpleCursorAdapter cursorAdaptor =
new SimpleCursorAdapter(this, R.layout.device, allDevices,
COLUMN_HEADINGS, DISPLAY_FIELDS);
deviceList.setAdapter(cursorAdaptor);
If I close the database inside the query() of the Provider, I get an
"Invalid statement in fillWindow()" error from the returned Cursor,
but I don't want to leave the database permanently open either. What
should I do?
--
You received this message because you are subscribed to the Google
Groups "Android Developers" group.
To post to this group, send email to android-developers@googlegroups.com
To unsubscribe from this group, send email to
android-developers+unsubscribe@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en
No comments:
Post a Comment