Like SavePOI()
, the DeletePOI()
method was created to simplify the logic in OnOptionsItemSelected()
. Before deleting the POI, we must ask the user to reconfirm by showing a dialog. Later in this chapter, we will show you how to display a confirmation prompt before initiating the deleted request.
We created the CreateOrUpdatePOIAsync()
method in POIDetailActivity
, let's now add another new method named DeletePOIAsync()
. This method performs pretty much the same task as the CreateOrUpdatePOIAsync()
method does in POIDetailActivity
. It checks for the Internet connection availability, initiates the delete operation asynchronously, and finally, notifies the user with a toast message.
Add the following DeletePOIAsync
method to your POIDetailActivity
class:
public async void DeletePOIAsync(){ POIService service = new POIService (); if (!service.isConnected(this)) { Toast toast = Toast.MakeText (this, "Not conntected to internet. Please check your device network settings...