Browse files

Done T0907-SwipeToDelete

  • Loading branch information...
GinaHsu committed Nov 1, 2017
1 parent f431a5e commit 8e7b59b59c792c9d915761e5b145089cf7227be1
@@ -18,6 +18,7 @@
import android.content.Intent;
import android.database.Cursor;
import android.os.Bundle;
@@ -80,11 +81,19 @@ public void onSwiped(RecyclerView.ViewHolder viewHolder, int swipeDir) {
// TODO (1) Construct the URI for the item to delete
//[Hint] Use getTag (from the adapter code) to get the id of the swiped item
// Retrieve the id of the task to delete
int id = (int) viewHolder.itemView.getTag();
//Build appropriate uri with String row id appended
String stringId = Integer.toString(id);
Uri uri = TaskContract.TaskEntry.CONTENT_URI;
uri = uri.buildUpon().appendPath(stringId).build();
// TODO (2) Delete a single row of data using a ContentResolver
getContentResolver().delete(uri, null, null);
// TODO (3) Restart the loader to re-query for all tasks after a deletion
//getSupportLoaderManager().restartLoader(TASK_LOADER_ID, null, MainActivity.this);

0 comments on commit 8e7b59b

Please sign in to comment.