开发者

How to send and retrieve the data from android app to some server

开发者 https://www.devze.com 2023-03-22 23:20 出处:网络
i\'am new to ANDROID. I have to send some data from my and开发者_如何学Pythonroid app to a local server and retrieve some information. How can i do that??? Please help mepublicvoid executeHttpPost(Str

i'am new to ANDROID. I have to send some data from my and开发者_如何学Pythonroid app to a local server and retrieve some information. How can i do that??? Please help me


public void executeHttpPost(String string) throws Exception { //This method for HttpConnection
try { HttpClient client = new DefaultHttpClient();

        HttpPost request = new HttpPost("url");

        List<NameValuePair> value=new ArrayList<NameValuePair>();

        value.add(new BasicNameValuePair("name",string));
        System.out.println("Json obj="+string);

        UrlEncodedFormEntity entity=new UrlEncodedFormEntity(value);

        request.setEntity(entity);

        client.execute(request);

       System.out.println("after sending :"+request.toString());

    } 
 catch(Exception e)     {System.out.println("Exp="+e);
    }

}
0

精彩评论

暂无评论...
验证码 换一张
取 消