Android的光标放在业务对象的通用列表?放在、光标、对象、业务

2023-09-07 14:06:28 作者:慵懒猫i

在.NET中的土地,我通常会查询数据库,并填充泛型列表的集合类型。然后,应用程序将使用它。

在Android的土地我一直在阅读有关数据库访问和应用程序使用。为什么大多数的文档中使用了一个光标,使用的常量的访问呢?这是节省资源吧?

解决方案   

这是节省资源吧?

没错。 +性能。 一般的规则是为了避免创建对象的w / o必要性,要在内存,CPU功率(并导致电池寿命)的限制和垃圾收集是相当昂贵的。

Android studio 4.1 不显示光标当前的类名 方法名

In .NET land I would normally query the database and 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.