开发者

Android Cursor over Generic list of business objects?

In .NET land I would normally query the database and开发者_如何学Python populate a generic List kind of collection. Then the app would use this.

In Android land I have been reading about DB access and use in apps. Why do most of the docs show the use of a cursor and use of constants to access it? Is this to save on resources perhaps?


Is this to save on resources perhaps?

Exactly. + performance.
The general rule is to avoid creating objects w/o necessity as you are limited on memory, cpu power (and resulting battery life) and garbage collection is rather expensive.


You can use the cursor for your adapter. Android is driven by listadatpers such as SimpleCursorAdapter. Using constant is a pro for design technique.

0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜