1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
JSON

{
    "STATUS": "SUCCESS",
    "place": [
        {
            "cafe_id": "28",
            "cafe_title": "Kiriya Café",
            "been": "2",
            "want": "1",
            "cafe_address": "Pasteur, Phnom Penh, Cambodia",
            "cafe_thumb": "6cf2cd825c5c9d7229449708e5459b81.jpg",
            "cafe_description": "#174, St 51 corner 370, Sangkat Boeung Keng Kang I, Khan Chamkarmorn, Phnom Penh, Kampot, Cambodia<br />\n<br />\nTEL: 016 363 730",
            "cafe_wifi_rate": "5",
            "cafe_coffee_rate": "5",
            "cafe_latitude": "11.548382623052275",
            "cafe_longitude": "104.9274871905518"
        }
    ]
}

private void sentPutRequest(String place_id, String uuid, String flag){
		class SendPutRegTask extends AsyncTask<String, Void, String>{

			@Override
			protected String doInBackground(String... params) {
				 String prmPlaceId = params[0];
				 String prmUuid = params[1];
				 String prmFlag = params[2];
				 String url = "http://xxx.xxx.xxx/xxx/been/";
				 
				 HttpClient httpClient = new DefaultHttpClient();
				 HttpPut httpPut = new HttpPut(url);
				 
				 List<NameValuePair> pairs = new ArrayList<NameValuePair>();
				 pairs.add(new BasicNameValuePair("place_id", prmPlaceId));
				 pairs.add(new BasicNameValuePair("uuid", prmUuid));
				 pairs.add(new BasicNameValuePair("flag", prmFlag));
				 
				 try {
					 httpPut.setEntity(new UrlEncodedFormEntity(pairs));
					 try {
						HttpResponse httpResponse = httpClient.execute(httpPut);
						InputStream inputStream = httpResponse.getEntity().getContent();
						InputStreamReader inputStreamReader = new InputStreamReader(inputStream);
						BufferedReader bufferedReader = new BufferedReader(inputStreamReader);
						StringBuilder sb = new StringBuilder();
						String line = null;
						while ((line = bufferedReader.readLine()) != null) {
							sb.append(line);
							Log.i("me",""+sb);
						}
						
						return sb.toString();
						
					} catch (ClientProtocolException e) {
						System.out.println("First Exception cuz of HttpResponese :" + e);
						e.printStackTrace();
					}
					
				} catch (IOException e) {
					System.out.println("Second Exception cuz of HttpResponse :" + e);
					 e.printStackTrace();
				}
				 
				return null;
			}
			
			@Override
			protected void onPostExecute (String result){
				super.onPostExecute(result);
				
				if(result.equals("working")){
	                Toast.makeText(getApplicationContext(), "HTTP POST is working...", Toast.LENGTH_LONG).show();
	            }else{
	                Toast.makeText(getApplicationContext(), "Invalid POST req...", Toast.LENGTH_LONG).show();
	            }
	        }           
	    }

	    SendPutRegTask sendPutRegTask = new SendPutRegTask();
	    sendPutRegTask.execute(place_id, uuid, flag);  
			
	}