如何删除http数据库中的一个特定行?我想像httpGet一样使用httpDelete,但它不起作用。
这是我的发布和删除代码。我很遗憾通过使用deleteMarkerData(),我删除整个表而不是一个。
public void postCarData() {
Thread t = new Thread() {
public void run() {
HttpClient client = new DefaultHttpClient();
HttpPost post = new HttpPost( CAR_URI);
try {
List<NameValuePair> nameValuePairs = new ArrayList<NameValuePair>(5);
nameValuePairs.add(new BasicNameValuePair("name", String.valueOf(lat)));
nameValuePairs.add(new BasicNameValuePair("description", ""));
nameValuePairs.add(new BasicNameValuePair("price", String.valueOf(lon)));
nameValuePairs.add(new BasicNameValuePair("product", UserLogin.accountName ));
nameValuePairs.add(new BasicNameValuePair("action", "put"));
post.setEntity(new UrlEncodedFormEntity(nameValuePairs));
HttpResponse response = client.execute(post);
BufferedReader rd = new BufferedReader(new InputStreamReader(response.getEntity().getContent()));
String line = "";
while ((line = rd.readLine()) != null) { Log.d(TAG, line); }
} catch (IOException e) { Log.d(TAG, "IOException while trying to conect to GAE"); }
}
};
t.start();
}
public void deleteCarData() throws ClientProtocolException, IOException {
HttpClient client = new DefaultHttpClient();
HttpDelete delete = new HttpDelete( CAR_URI );
client.execute(delete);
}
答案 0 :(得分:1)
你问的是服务器的DELETE方法为什么会这样做的问题,而你已经发布了一个带有DELETE方法客户端代码的问题。在不知道CAR_URI背后的服务器
的情况下,无法回答这个问题