开发者

XML array from SQLite database

开发者 https://www.devze.com 2022-12-29 14:46 出处:网络
I am using SQLite to store school classes.I want to fill in a Spinner with the classes that get stored in the database.How would I grab all the classes in the DB and load them into a s开发者_开发知识库

I am using SQLite to store school classes. I want to fill in a Spinner with the classes that get stored in the database. How would I grab all the classes in the DB and load them into a s开发者_开发知识库pinner?


Step #1: Use query() or rawQuery() to get a Cursor with the results of a query on your database.

Step #2: Wrap the Cursor in a CursorAdapter, set to populate rows with your database results.

Step #3: Attach the CursorAdapter to the Spinner.

Here is a sample project showing using a CursorAdapter with a database query, but for a ListView. Here is a sample project showing using a CursorAdapter with a Spinner, but from a query against a content provider, not a database.

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号