0

Hi i want to delete record from database, i am using following code, but record is not being deleted,

HttpClient client = new DefaultHttpClient();
HttpConnectionParams.setConnectionTimeout(client.getParams(), 10000);
HttpDelete delete = new HttpDelete(URL)

HttpResponse response = client.execute(delete);

please help me to solve it. is this a right way or is there any other method for it??

Rajesh Panchal
  • 1,140
  • 3
  • 20
  • 39

1 Answers1

0

HTTP DELETE method

The HTTP DELETE method is defined in section 9.7 of RFC2616:

The DELETE method requests that the origin server delete the resource identified by the Request-URI. [...] The client cannot be guaranteed that the operation has been carried out, even if the status code returned from the origin server indicates that the action has been completed successfully.

Please Ref : http://developer.android.com/reference/org/apache/http/client/methods/HttpDelete.html

i got the same problem , i changed to HttpPut() in Server and Client. then it was working.

create a HTTP Put() in server make the same functionality of Delete (deleting something from DataBase) and in the client side you can call by

HttpPut put = new HttpPut(URL); HttpResponse response = client.execute(put);

Rajesh Mikkilineni
  • 854
  • 10
  • 22
  • can you please guide me how can i set HttpPut() ? DO i have to set it like below ? HttpClient client = new DefaultHttpClient(); HttpConnectionParams.setConnectionTimeout(client.getParams(), 10000); HttpPut put = new HttpPut(URL) HttpResponse response = client.execute(put); – Rajesh Panchal Sep 11 '14 at 13:14
  • Updated my Answer please have a look – Rajesh Mikkilineni Sep 11 '14 at 13:23