How to Save an ArrayList of Custom Objects to SharedPreferences with Gson in Android

Full source code to save a List of custom Objects to Shared Preferences using Google’s GSON Library. For this purpose we will turn the ArrayList into a JSON and save it as a String using the putString method Gradle: activity_main.xml example_item.xml ExampleAdapter.java ExampleItem.java MainActivity.java