在Android中将Loader对象设为单例

时间:2014-06-08 07:25:54

标签: android sqlite android-loadermanager commonsware-cwac

我正在通过commonsware使用Sqlite加载器lib,即cwac-loaderex。将Sqlite加载程序对象设为单例是不错的做法?。

让我们说,在新活动中我想插入一条新记录,所以我必须在Loader对象上执行此操作,以便将其反映在我的UI上。

但是在新活动中,我不想像这样加载表格的所有内容

loader=
        new SQLiteCursorLoader(this, db, "SELECT _ID, title, value "
            + "FROM constants ORDER BY title", null);

相反,通过singleton使用共享加载器对象是否合适?

编辑:

yes i know its deprecated. Here my question is. Lets say that i have created a sqlite loader object and displayed the contents on listview, and i will click on add new item button, it will take me to a new activity, ill fill out the details and press add. In this case the added object to reflect on listview we need to perform insert operation on sqliteloader object, so should i have to pass this object from listview via intent or is it ok to create a new sqliteloader object in the current activity and perform operation?

1 个答案:

答案 0 :(得分:1)

  

我通过commonsware使用Sqlite加载器lib,即cwac-loaderex。

请不要。该项目已停止,如项目主页上的全帽大写字母所示。

  

将Sqlite加载程序对象设为单例是不错的做法?。

没有