I try to build to app, that it show a route with polylines, I need to add and remove polylines with conditionals, from a String that is equal to inicioR for show, and finR for remove
Below code fragment of my activity.java. I try to do it like
@Override
public void onDirectionFinderSuccess(List<Route> routes) {
    progressDialog.dismiss();
    polylinePaths = new ArrayList<>();
    originMarkers = new ArrayList<>();
    waypoints = new ArrayList<>();
    destinationMarkers = new ArrayList<>();
    for (Route route : routes) {
        //mMap.moveCamera(CameraUpdateFactory.newLatLngZoom(route.startLocation, 16));
        ((TextView) findViewById(R.id.tvDuration)).setText(route.duration + " Min");
        ((TextView) findViewById(R.id.tvDistance)).setText(route.distance + " Kms");
        PolylineOptions polylineOptions = new PolylineOptions().
                geodesic(true).
                color(Color.BLUE).
                width(10);
        for (int i = 0; i < route.points.size(); i++)
            polylineOptions.add(route.points.get(i));
        if (estado == "inicioR") {
            polylinePaths.add(mMap.addPolyline(polylineOptions));
        }else if (estado == "finR"){
            polylinePaths.remove(mMap.addPolyline(polylineOptions));
        }
    }
}
 
     
    