You can store the resourceId of the image for each maker in the SharedPreferences.
Then you can grab that Id and set the icon by using the icon()
method and by passing in BitmapDescriptorFactory.fromResource(resourceId)
. In other words,
When you want to save the resourceId, use
prefs.edit().putInt(KEY_FOR_MARKER_ICON, iconResourceId);
Then grab the Id when you want to display it later.
prefs.getInt(KEY_FOR_MARKER_ICON, 0);
markerOptions.icon(BitmapDescriptorFactory.fromResource(resourceId));
I think your code will work if you look at your onCreate()
code and just change
marker = gMap.addMarker(new MarkerOptions().position(point));
to
marker = gMap.addMarker(new MarkerOptions().position(point)
.icon(BitmapDescriptorFactory.fromResource(R.drawable.b)));