POJO的与光标在Android中 [英] POJO's versus Cursors in Android

查看:98
本文介绍了POJO的与光标在Android中的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我通常倾向于定义使用我的应用程序POJO的,如文章,评论等模型层。

I usually tend to define the model layer of my apps using POJO's, such as Article, Comment, etc.

我要实现我的列表视图之一的适配器的AlphabetIndexer。现在,该适配器接受一个收集的文章,这是我从我的身边一个SQLiteDatabase包装通常会得到。

I was about to implement an AlphabetIndexer in the adapter of one of my ListViews. Right now this adapter accepts a Collection of Articles, which I normally get from my wrapper around an SQLiteDatabase.

在AlphabetIndexer建筑工的签名如下:

The signature of the AlphabetIndexer constructer is as follows:

public AlphabetIndexer (Cursor cursor, int sortedColumnIndex, CharSequence alphabet)

由于此不接受集合或类似的东西,只是一个指针,它让我想:也许我不应该对我的模型创建对象,而只是使用游标从数据库返回

Since this doesn't accept a Collection or something similar, just a Cursor, it got me wondering: maybe I shouldn't be creating objects for my model, and just use the Cursors returned from the database?

所以在问题是,我想:我该怎么办与POJO的的集合,再present数据,或使用光标在我的应用程序,只是工作

So the question is, I guess: what should I do, represent data with Collections of POJO's, or just work with Cursors throughout my app?

任何输入?

推荐答案

我遇到了类似的问题。现在,我从POJO的抚育之遥。但是请注意,你可以创建自己的光标接口的POJO的集合,如果你选择这样做。

I have run into similar issues. Right now, I am tending away from POJOs. Note, though, that you can create your own Cursor interface for a collection of POJOs, if you so choose.

这篇关于POJO的与光标在Android中的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆