Android httpclient php_mysql

4,045 views
3,708 views

Published on

Android tutorial guide
HTTPClient & PHP MySQL
by Chalermchon Sommana
at Roi-et Hostpital
date 28Feb - 1 Mar 2011

see more android/iOS application Development : http://adayd3sign.wordpress.com/
join me : http://www.brightest-idea.com

Published in: Technology
2 Comments
4 Likes
Statistics
Notes
No Downloads
Views
Total views
4,045
On SlideShare
0
From Embeds
0
Number of Embeds
3
Actions
Shares
0
Downloads
146
Comments
2
Likes
4
Embeds 0
No embeds

No notes for slide

Android httpclient php_mysql

  1. 1. ANDROIDHTTPCLIENT & PHP MYSQL 28Feb - 1Mar 2011 ณ โรงพยาบาลรอยเอ็ด จังหวัดรอยเอ็ด Special Course วิทยากร เฉลิมชนม สมณะ
  2. 2. Outline• Day 1 – Get Start and Setup tool – Create Simple application – Simple Connect PHP MySQL: select • Day 2 – Simple Connect PHP MySQL: select insert update delete – ListView UI Android: HTTPCLIENT & PHP MYSQL 28 Feb 2 - 1 Mar
  3. 3. ExampleAndroid: HTTPCLIENT & PHP MYSQL 28 Feb 3 - 1 Mar
  4. 4. Get Start• Install SDK• Install ADT in eclipse• Create simple application “Hello World” – Android File & Folder: R.java manifestfile.xml layout.xml – Basic UI – How to use Simulator Android: HTTPCLIENT & PHP MYSQL 28 Feb 4 - 1 Mar
  5. 5. Simple Application• Activity• method: onCreate• findViewByID Android: HTTPCLIENT & PHP MYSQL 28 Feb 5 - 1 Mar
  6. 6. Connect PHP MySQL• Overview Select request Insert response Connect DB Update MySQL Delete Android: HTTPCLIENT & PHP MYSQL 28 Feb 6 - 1 Mar
  7. 7. HttpClient (code)//connect• HttpClient httpClient = new DefaultHttpClient();• HttpPost httpPost = new HttpPost(url);• httpPost.setEntity(new UrlEncodedFormEntity(param));• HttpResponse httpRespose = httpClient.execute(httpPost);• HttpEntity httpEntity = httpRespose.getEntity();//read content• InputStream in = httpEntity.getContent();• BufferedReader read = new BufferedReader(new InputStreamReader(in));• String content = "";• String line = "";• while((line = read.readLine())!=null){ content += line;• } Android: HTTPCLIENT & PHP MYSQL 28 Feb 7 - 1 Mar
  8. 8. Post Parameter • Overview Key + value $w = $_REQUEST[‘whereId’]param.add(new BasicNameValuePair("whereId", "19")); or $w = $_POST[‘whereId’] NameValuePair Request+parameter Insert response Update Android: HTTPCLIENT & PHP MYSQL 28 Feb 8 - 1 Mar
  9. 9. Post Parameter (code)• ArrayList<NameValuePair> param = new ArrayList<NameValuePair>();//test select: whereId• param.add(new BasicNameValuePair("whereId", "19"));//add parameter• httpPost.setEntity(new UrlEncodedFormEntity(param)); Android: HTTPCLIENT & PHP MYSQL 28 Feb 9 - 1 Mar
  10. 10. Thank You. Android: HTTPCLIENT & PHP MYSQL 28 Feb 10 - 1 Mar

×