'how to delete android recyclerview data through php api using retrofit into adaptor?
I try to use the following code but doesn't work at all. When I hit delete button, nothing is happening and query is also not getting deleted.
holder.delete.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
deletedata();
}
private void deletedata() {
Retrofit retrofit=new Retrofit.Builder()
.baseUrl(baseU)
.addConverterFactory(GsonConverterFactory.create())
.build();
myApi=retrofit.create(MyApi.class);
Call<Modelclass>call=myApi.deleteDate(id);
call.enqueue(new Callback<Modelclass>() {
@Override
public void onResponse(Call<Modelclass> call, Response<Modelclass> response) {
Toast.makeText(context, "data deleted", Toast.LENGTH_SHORT).show();
}
@Override
public void onFailure(Call<Modelclass> call, Throwable t) {
Toast.makeText(context, "data not deleted", Toast.LENGTH_SHORT).show();
}
});
}
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|
