title: Can't delete and create data on Fragment Activity
body: <p>I'm trying to delete and create a data string from a API webpage but i can't get the error code
  I create API website from native php. But i create data on postman work insert and delete data</p>
  
  <p>Code Delete Data</p>
  
  <pre><code>package com.dev.kedaiit.sibooks.ui.kategori;
  
  import android.app.ProgressDialog;
  import android.content.Intent;
  import android.os.Bundle;
  import android.util.Log;
  import android.view.View;
  import android.widget.Button;
  import android.widget.EditText;
  import android.widget.Toast;
  
  import androidx.appcompat.app.AppCompatActivity;
  
  import com.android.volley.AuthFailureError;
  import com.android.volley.Request;
  import com.android.volley.Response;
  import com.android.volley.VolleyError;
  import com.android.volley.toolbox.StringRequest;
  import com.dev.kedaiit.sibooks.MainActivity;
  import com.dev.kedaiit.sibooks.R;
  import com.dev.kedaiit.sibooks.util.AppController;
  import com.dev.kedaiit.sibooks.util.ServerAPI;
  
  import org.json.JSONException;
  import org.json.JSONObject;
  
  import java.util.HashMap;
  import java.util.Map;
  
  public class DeleteKategori extends AppCompatActivity {
      EditText deleteID ;
      Button btnDelete;
      ProgressDialog pd;
  
      @Override
      protected void onCreate(Bundle savedInstanceState) {
          super.onCreate(savedInstanceState);
          setContentView(R.layout.activity_delete_kategori);
  
          deleteID = (EditText) findViewById(R.id.id_kategori);
          btnDelete = (Button) findViewById(R.id.btn_delete);
          pd = new ProgressDialog(DeleteKategori.this);
  
          btnDelete.setOnClickListener(new View.OnClickListener() {
              @Override
              public void onClick(View view) {
                  deleteData();
              }
          });
      }
  
      private void deleteData()
      {
          pd.setMessage("Delete Data ...");
          pd.setCancelable(true);
          pd.show();
  
          StringRequest delReq = new StringRequest(Request.Method.POST, ServerAPI.URL_DELETE_KATEGORI, new Response.Listener&lt;String&gt;() {
                      @Override
                      public void onResponse(String response) {
                          pd.cancel();
                          Log.d("volley","response : " + response.toString());
                          try {
                              JSONObject res = new JSONObject(response);
                              Toast.makeText(DeleteKategori.this,"Successs" +res.getString("message"), Toast.LENGTH_SHORT).show();
  
                          } catch (JSONException e) {
                              e.printStackTrace();
                          }
  
  
                          startActivity(new Intent(DeleteKategori.this, KategoriFragment.class));
                      }
                  },
                  new Response.ErrorListener() {
                      @Override
                      public void onErrorResponse(VolleyError error) {
                          pd.cancel();
                          Log.d("volley", "error : " + error.getMessage());
                          Toast.makeText(DeleteKategori.this, "ERROR DELETE DATA", Toast.LENGTH_SHORT).show();
                      }
                  }){
              @Override
              protected Map&lt;String, String&gt; getParams() throws AuthFailureError {
                  Map&lt;String, String&gt; map = new HashMap&lt;&gt;();
                  map.put("id_kategori",deleteID.getText().toString());
                  return map;
              }
          };
  
          AppController.getInstance().addToRequestQueue(delReq);
      }
  }
  
  
  
  </code></pre>
  
  <p>Code Insert Data</p>
  
  <pre><code>package com.dev.kedaiit.sibooks.ui.kategori;
  
  import android.app.ProgressDialog;
  import android.content.Intent;
  import android.os.Bundle;
  import android.view.View;
  import android.widget.Button;
  import android.widget.EditText;
  import android.widget.Toast;
  
  import androidx.appcompat.app.AppCompatActivity;
  
  import com.android.volley.AuthFailureError;
  import com.android.volley.Request;
  import com.android.volley.Response;
  import com.android.volley.VolleyError;
  import com.android.volley.toolbox.StringRequest;
  import com.dev.kedaiit.sibooks.R;
  import com.dev.kedaiit.sibooks.util.AppController;
  import com.dev.kedaiit.sibooks.util.ServerAPI;
  
  import org.json.JSONException;
  import org.json.JSONObject;
  
  import java.util.HashMap;
  import java.util.Map;
  
  public class InsertKategori extends AppCompatActivity {
      EditText id_kategori, kategori;
      Button btnBatal, btnSimpan;
      ProgressDialog pd;
  
      @Override
      protected void onCreate(Bundle savedInstanceState) {
          super.onCreate(savedInstanceState);
          setContentView(R.layout.activity_insert_kategori);
  
          /*get data from intent*/
          Intent data = getIntent();
          final int update = data.getIntExtra("update",0);
          String intent_idkategori = data.getStringExtra("id_kategori");
          String intent_kategori = data.getStringExtra("kategori");
          /*end get data from intent*/
  
  //        id_kategori = (EditText) findViewById(R.id.idkategori);
          kategori = (EditText) findViewById(R.id.edt_kategori);
          btnBatal = (Button) findViewById(R.id.btn_cancel);
          btnSimpan = (Button) findViewById(R.id.btn_simpan);
          pd = new ProgressDialog(InsertKategori.this);
  
          /*kondisi update / insert*/
          if(update == 1)
          {
              btnSimpan.setText("Update Data");
              id_kategori.setText(intent_idkategori);
              id_kategori.setVisibility(View.VISIBLE);
              kategori.setText(intent_kategori);
  
          }
  
  
          btnSimpan.setOnClickListener(new View.OnClickListener() {
              @Override
              public void onClick(View view) {
                  if(update == 1)
                  {
                      Update_data();
                  }else {
                      simpanData();
                  }
              }
          });
  
          btnBatal.setOnClickListener(new View.OnClickListener() {
              @Override
              public void onClick(View view) {
                  Intent main = new Intent(InsertKategori.this,KategoriFragment.class);
                  startActivity(main);
              }
          });
      }
  
      private void Update_data()
      {
          pd.setMessage("Update Data");
          pd.setCancelable(true);
          pd.show();
  
          StringRequest updateReq = new StringRequest(Request.Method.POST, ServerAPI.URL_UPDATE_KATEGORI,
                  new Response.Listener&lt;String&gt;() {
                      @Override
                      public void onResponse(String response) {
                          pd.cancel();
                          try {
                              JSONObject res = new JSONObject(response);
                              Toast.makeText(InsertKategori.this, ""+   res.getString("message") , Toast.LENGTH_SHORT).show();
                          } catch (JSONException e) {
                              e.printStackTrace();
                          }
  
                          startActivity( new Intent(InsertKategori.this,KategoriFragment.class));
                      }
                  },
                  new Response.ErrorListener() {
                      @Override
                      public void onErrorResponse(VolleyError error) {
                          pd.cancel();
                          Toast.makeText(InsertKategori.this, "Gagal Insert Data", Toast.LENGTH_SHORT).show();
                      }
                  }){
              @Override
              protected Map&lt;String, String&gt; getParams() throws AuthFailureError {
                  Map&lt;String,String&gt; map = new HashMap&lt;&gt;();
                  map.put("id_kategori",id_kategori.getText().toString());
                  map.put("kategori",kategori.getText().toString());
  
                  return map;
              }
          };
  
          AppController.getInstance().addToRequestQueue(updateReq);
      }
  
  
  
      private void simpanData()
      {
  
          pd.setMessage("Menyimpan Data");
          pd.setCancelable(true);
          pd.show();
  
          StringRequest sendData = new StringRequest(Request.Method.POST, ServerAPI.URL_INSERT_KATEGORI,
                  new Response.Listener&lt;String&gt;() {
                      @Override
                      public void onResponse(String response) {
                          pd.cancel();
                          try {
                              JSONObject res = new JSONObject(response);
                              Toast.makeText(InsertKategori.this, ""+   res.getString("message") , Toast.LENGTH_SHORT).show();
                          } catch (JSONException e) {
                              e.printStackTrace();
                          }
  
                          startActivity( new Intent(InsertKategori.this,KategoriFragment.class));
                      }
                  },
                  new Response.ErrorListener() {
                      @Override
                      public void onErrorResponse(VolleyError error) {
                          pd.cancel();
                          Toast.makeText(InsertKategori.this, "Gagal Insert Data", Toast.LENGTH_SHORT).show();
                      }
                  }){
              @Override
              protected Map&lt;String, String&gt; getParams() throws AuthFailureError {
                  Map&lt;String,String&gt; map = new HashMap&lt;&gt;();
                  map.put("id_kategori",id_kategori.getText().toString());
                  map.put("kategori",kategori.getText().toString());
                  return map;
              }
          };
  
          AppController.getInstance().addToRequestQueue(sendData);
      }
  
  }
  
  </code></pre>
  
  <p>Fragment Kategori</p>
  
  <pre><code>package com.dev.kedaiit.sibooks.ui.kategori;
  
  import android.app.ProgressDialog;
  import android.content.Intent;
  import android.os.Bundle;
  import android.util.Log;
  import android.view.LayoutInflater;
  import android.view.View;
  import android.view.ViewGroup;
  
  import androidx.fragment.app.Fragment;
  import androidx.recyclerview.widget.DividerItemDecoration;
  import androidx.recyclerview.widget.LinearLayoutManager;
  import androidx.recyclerview.widget.RecyclerView;
  
  import com.android.volley.Request;
  import com.android.volley.RequestQueue;
  import com.android.volley.Response;
  import com.android.volley.VolleyError;
  import com.android.volley.toolbox.JsonObjectRequest;
  import com.android.volley.toolbox.Volley;
  import com.dev.kedaiit.sibooks.R;
  import com.dev.kedaiit.sibooks.adapter.AdapterDataKategori;
  import com.dev.kedaiit.sibooks.model.DataKategori;
  import com.dev.kedaiit.sibooks.util.ServerAPI;
  import com.google.android.material.floatingactionbutton.FloatingActionButton;
  
  import org.json.JSONArray;
  import org.json.JSONException;
  import org.json.JSONObject;
  
  import java.util.ArrayList;
  import java.util.List;
  
  public class KategoriFragment extends Fragment {
      private RecyclerView recyclerView;
      private FloatingActionButton floatingActionButton;
      private LinearLayoutManager linearLayoutManager;
      private DividerItemDecoration dividerItemDecoration;
      private List&lt;DataKategori&gt; list;
      private RecyclerView.Adapter adapter;
  
  
      public KategoriFragment() {
          // Required empty public constructor
      }
  
      @Override
      public View onCreateView(final LayoutInflater inflater, final ViewGroup container, Bundle savedInstanceState) {
  
          final View view = inflater.inflate(R.layout.fragment_kategori, container, false);
  
          recyclerView = view.findViewById(R.id.recyclerViewKategori);
  
          list = new ArrayList&lt;DataKategori&gt;();
          adapter = new AdapterDataKategori(getContext(), list);
  
          linearLayoutManager = new LinearLayoutManager(getContext());
          linearLayoutManager.setOrientation(LinearLayoutManager.VERTICAL);
          dividerItemDecoration = new DividerItemDecoration(recyclerView.getContext(), linearLayoutManager.getOrientation());
  
          recyclerView.setHasFixedSize(true);
          recyclerView.setLayoutManager(linearLayoutManager);
          recyclerView.addItemDecoration(dividerItemDecoration);
          recyclerView.setAdapter(adapter);
  
  
          FloatingActionButton fab = (FloatingActionButton) view.findViewById(R.id.fab);
          FloatingActionButton delKtg = (FloatingActionButton) view.findViewById(R.id.delKtg);
  
          fab.setOnClickListener(new View.OnClickListener() {
              @Override
              public void onClick(View view) {
                  Intent intent = new Intent(view.getContext(), InsertKategori.class);
                  startActivity(intent);
              }
          });
  
          delKtg.setOnClickListener(new View.OnClickListener() {
              @Override
              public void onClick(View view) {
                  Intent intent = new Intent(view.getContext(),DeleteKategori.class);
                  startActivity(intent);
              }
          });
  
          getData();
  
          return view;
      }
  
      private void getData() {
          final ProgressDialog progressDialog = new ProgressDialog(getContext());
          progressDialog.setMessage("Loading...");
          progressDialog.show();
  
          JsonObjectRequest my_request = new JsonObjectRequest(Request.Method.GET, ServerAPI.URL_DATA_KATEGORI, null, new Response.Listener&lt;JSONObject&gt;() {
              @Override
              public void onResponse(JSONObject response) {
                  try{
                      JSONArray jsonArray = response.getJSONArray("data");
                      for (int i = 0; i &lt; jsonArray.length(); i++) {
  
                          JSONObject Jobj = jsonArray.getJSONObject(i);
  
                          DataKategori obj = new DataKategori();
                          obj.setId_kategori(Jobj.getString("id_kategori"));
                          obj.setKategori(Jobj.getString("kategori"));
  
                          list.add(obj);
  
                      }
                  } catch (JSONException e) {
                      e.printStackTrace();
                      progressDialog.dismiss();
                  }
                  adapter.notifyDataSetChanged();
                  progressDialog.dismiss();
              }
          }, new Response.ErrorListener() {
  
              @Override
              public void onErrorResponse(VolleyError error) {
                  Log.e("Volley", "Error: " + error.getMessage());
                  progressDialog.dismiss();
              }
          });
  
          RequestQueue requestQueue = Volley.newRequestQueue(getContext());
          requestQueue.add(my_request);
      }
  }
  </code></pre>
  
  <p><a href="https://github.com/bellabeen/sibooks-client" rel="nofollow noreferrer">https://github.com/bellabeen/sibooks-client</a> This project me get this in the logcat and when i dont get error code</p>