【发布时间】:2017-03-06 08:25:51
【问题描述】:
我想列出我在数据库中存储的所有数据,并在使用回收器视图/适配器时显示它。谁能帮我解决这个问题。
-我有一个getter和setter类(PWClass)
这是我的一些代码:
这是我在类中存储一些数据并将其添加到列表中的时间,但这只是一个示例。
PWClass pwc = new PWClass("Facebook", "Action & Adventure", "2015");
pwList.add(pwc);
pwc = new PWClass("Instagram", "Action & Adventure", "2015");
pwList.add(pwc);
mAdapter.notifyDataSetChanged();
我的问题是如何结合上面的代码并在数据库上调用查询以显示如下数据:
//i declare on top
private List<PWClass> pwList = new ArrayList<>();
private RecyclerView recyclerView;
private PWAdapter mAdapter;
Database controller;
//and from a method below
pwList.add(controller.add_pw());//adding on list array by calling my db method
我应该使用一些 for/while 循环/数组吗?我在想上面的代码,但我知道它错了。你明白我的意思吗?
请帮助我了解更多,感谢您的建议,谢谢!
【问题讨论】:
标签: android sqlite arraylist android-recyclerview adapter