I have a List<Sendero>
that is populated from a database, I want to avoid recharging data from the database when the device rotates
I mean I want to save the list so I can get it back in onCreate
using savedInstanceState
To save
The same Android-Studio generates the following code:
private List<Route> listData;
@Override
public void onSaveInstanceState(Bundle outState) {
outState.putParcelableArrayList("list_data", (ArrayList<? extends Parcelable>) listData);
super.onSaveInstanceState(outState);
}
The problem comes when it comes to recovering, a warning indicates.
if (savedInstanceState != null) {
listData = (List<Route>) savedInstanceState.getSerializable("list_data");
}
Warning following:
Unchecked cast: 'java.io.Serializable' to 'java.util.List<app.....models.Route>'