I am using room database for storing json data from URL its working fine but while accessing data from data base to show on recyclerview its give one result at time and if i am open app second time then second object is showing, i am new in room can any one suggest me how to do this my code is.
App my pojo class.
My Adapter Class is.
recyclerView = view.findViewById(R.id.recyclerView);
postsAdapter = new PostsAdapter(new ArrayList<Example>());
recyclerView.setLayoutManager(new LinearLayoutManager(getActivity()));
addBorrowViewModel = ViewModelProviders.of(this).get(AddBorrowViewModel.class);
addBorrowViewModel.getItemAndPersonList().observe(getActivity(), new Observer<List<Example>>() {
@Override
public void onChanged(@Nullable List<Example> itemAndPeople)
{
recyclerViewAdapter.addAll(itemAndPeople);
}
});
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…