I've been trying to save an integer array list in shared preferences for a couple of days now but cannot figure out how to do it.
here's the array list i'm trying to save
////list that contains checked routes///
ArrayList<Integer> checkedRoutePosition = new ArrayList<>();
and here's how the array obtains the values within it
int listViewItemPosition = ((Activity) getContext()).getIntent().getIntExtra("listViewItemPosition",0);
checkedRoutePosition.add(listViewItemPosition);
In another activity after you click the back button a new intent is started that takes me to this activity. The intent passes in the listViewItemPosition value that I need to save to the array.
The above lines of code are in my getView method of my custom adapter for a listview. After saving them I want to compare them to position in my getView. Where the values are equal I want to set a certain image. Is this code the right way to do that?
for(int i=0; i<checkedRoutePosition.size(); i++)
if(position == checkedRoutePosition.get(i)) {
checkImageView.setImageResource(checkImageResourceId);
}
Thanks for any help!