Moved the activity finish to the end of the method so that the database calls will be executed for sure before the activity finishes.