So I have arraylist modelData
that populates a recyclerview using sqlite database in some activity.!
Now in my MainActivity
I want an string arraylist of names from the modelData
!
that's what did so far..
// inside the onCreate of MainActivity
//code ..
db = new DBHandler(this, null, null, 1);
modelData = new ArrayList<AzkarModel>();
modelData = db.getDataFromDB();
for (AzkarModel o : modelData) {
ArrayList<String> names = new ArrayList<>();
names.add(o.getName());
}
for (int i = 0; i< modelData.size();i++){
names.add(modelData.get(i).getName());
Log.i("The List Log", names);
}
Two problems
1) [FIXED] The names
arraylist is showing the same element twice at first and end
I/ The List Log: [Mike, John, Sam, Nora, Mike]
2) The arraylist names
doesn't get updated..! when I add/edit/delete from the recycler and go back to the MainActivity
I don't see the new changes unless I close the app then open it again..! I can't use notifyDataSetChanged
since there's no adapter here.!