the cheapest car insurance cost of car insurance best car insurance quotes insurance auto insurance quotes car get car insurance quotes online car insurance agent instant car insurance quote car insurance websites direct car insurance insure a car motor car insurance quote cheap car insurance online quotes for car insurance car insurers commercial car insurance motor insurance quote car insurance quotes online get a quote online international health insurance compare car insurance quotes insurance for car compare car insurance car insurance buy life insurance online compare auto insurance international medical insurance general car insurance cheap motor insurance low car insurance car insurance comparison company car insurance budget car insurance private health insurance online quote car insurance cheap motor car insurance car insurance for new drivers cheap car insurance quotes online online car insurance quotes get car insurance quotes car insurance quotes comparison motor car insurance car insurance quotes car insurance cheap comprehensive car insurance best auto insurance short term health insurance motor insurance cheap online car insurance online motor insurance quotes car insurance california buycarinsurance online vehicle insurance free car insurance quotes landlord insurance health insurance for children motorbike insurance monthly car insurance car insurance usa car insurance reviews car insurance renewal quotes vehicle insurance health insurance rates term life insurance quotes vehicle insurance quotes car insurance compare motor vehicle insurance best car insurance motor insurance online quote car insurance online quote life insurance online supplemental health insurance best car insurance rates car insurance discounts motor vehicle insurance quotes auto insurance cheap travel insurance bike insurance travel medical insurance buy car insurance online online motor insurance travel insurance quote get a quote for car insurance health insurance agent car insurance companies cheap car insurance companies travel insurance annual travel insurance commercial vehicle insurance permanent life insurance medical insurance quotes online car insurance cheap car insurance quotes car insurance online quote insurance online level term life insurance health insurance comparison how much is car insurance travel health insurance pet health insurance quotes on cars health ins travel insurance uk quote for car insurance get insurance quote online disability insurance quote temporary health insurance temporary insurance rental car insurance cheap health insurance auto insurance compare third party car insurance buy health insurance auto insurance quotes cheap insurance companies best term life insurance personal health insurance online quote insurance car insurance premium health insurance policies quotes for cars whole life insurance credit insurance cheap van insurance cheap term life insurance cheap motorcycle insurance compare life insurance car insurance cover health insurance motorcycle insurance short term car insurance health insurance coverage insurance qoute cheap life insurance house insurance quote car insurance uk health insurance companies cigna health insurance cheap insurance cheap car insurance uk compare health insurance car insurance for young drivers short term insurance online health insurance caravan insurance life insurance comparison direct insurance health insurance plans motor insurance online car insurance estimator accident insurance home insurance quotes nj car insurance new car insurance private medical insurance home insurance car insurance brokers car insurance rates commercial insurance health insurance quotes motor insurance companies which car insurance car quotes online online auto insurance flood insurance cheap auto insurance quotes car insurance agencies business health insurance term life insurance truck insurance professional indemnity insurance life insurance car insurance policy long term care insurance drive insurance buy insurance car ins motorcycle insurance quote critical illness insurance term insurance student health insurance home insurance comparison insurance rates insurance cover holiday insurance insurance sites online vehicle insurance quotes company website home insurance rates compare insurance buy insurance online affordable medical insurance car insurance coverage product liability insurance home contents insurance buy life insurance renters insurance group health insurance family health insurance motor insurance quote online mortgage insurance best home insurance personal insurance medical insurance property insurance life insurance agent group insurance aetna health insurance cheap medical insurance liability insurance rental insurance life insurance policy group life insurance general liability insurance insurance quotes online all car insurance companies best health insurance insurance plans life insurance for seniors van insurance website quote universal life insurance building insurance co insurance insurance car car insurance prices disability insurance insurance vehicle cheap vehicle insurance senior life insurance medical insurance plans insurance health house insurance life insurance quotes car quotes cheap home insurance business insurance com bank credit card lowest credit card eligibility no fee credit cards best credit card compare how can i apply for credit card business credit cards cheapest credit card company credit card corporate credit card apply for a credit card online 0 apr credit cards how can i get credit card get a credit card open credit card usa credit card instant credit card approval store credit cards credit card shopping airline miles credit card frequent flyer credit cards hotel credit cards best credit card deals compare credit miles credit card credit card consolidation college student credit cards how do i apply for a credit card gold credit card how to open credit card apply for credit card eligibility for credit card credit card verification credit card offers online credit card application form which credit card to apply how can i get a credit card credit card online apply credit cards uk 0 credit cards looking for credit card offers credit card information bank credit card application travel credit cards what is a credit card credit card sign up master credit card cash back cards platinum credit card compare visa cards credit bank credit card no interest credit cards cheap credit cards 0 credit card offers online credit new credit cards application of credit card how to apply for credit card apply card credit online credit card deals premier credit card mastercard credit card how to get credit card apply credit card credit card application credit companies creditcard cash back credit cards airline credit cards cash credit card credit card rates student credit cards apply credit card online how to apply credit card interest free credit card secured credit card best travel credit card capital one credit card online credit card application credit cards with no annual fee new credit card offers apply online credit card credit card apply online best rewards credit card city credit card how to get a credit card credit card counseling rebate credit card mastercard debit card credit card debt best credit cards to apply for best credit cards apply for credit card online credit card apply how to apply for a credit card apply for new credit card credit card rebate best credit card comparison apply for visa card online cim credit card good credit cards credit card cash back best cash back credit cards mastercard credit card application credit card checker credit card mastercard instant credit card card compare credit card rewards programs compare the best credit cards apply visa card cash rebate credit card bankruptcy credit cards card offers instant approval credit cards credit card online application credit cards for students how to sign up for credit card uk credit cards credit card account about credit card visa card apply online credit card compare site secured mastercard visa card application credit card rewards credit rating how can we get credit card visa credit card rewards card online credit card processing capital credit card credit card visa consolidate credit cards credit card processing credit card reviews apply new credit card business credit card application credit cards with cash back credit card reader credit card instant approval online apply credit card bad credit credit cards credit card selection online visa card pay with credit card credit card charges visa or mastercard credit card machine apply a credit card small business credit cards prepaid debit cards visa debit card mbna credit card credit card terminal card credit application credit card generator credit card balance credit card numbers credit card transfer credit card interest rates credit card interest gold card credit card online best rate credit cards credit card low interest visa card online online credit card how to apply a credit card 0 interest credit cards debit card the cheapest car insurance cost of car insurance best car insurance quotes insurance auto insurance quotes car get car insurance quotes online car insurance agent instant car insurance quote car insurance websites direct car insurance insure a car motor car insurance quote cheap car insurance online quotes for car insurance car insurers commercial car insurance motor insurance quote car insurance quotes online get a quote online international health insurance compare car insurance quotes insurance for car compare car insurance car insurance buy life insurance online compare auto insurance international medical insurance general car insurance cheap motor insurance low car insurance car insurance comparison company car insurance budget car insurance private health insurance online quote car insurance cheap motor car insurance car insurance for new drivers cheap car insurance quotes online online car insurance quotes get car insurance quotes car insurance quotes comparison motor car insurance car insurance quotes car insurance cheap comprehensive car insurance best auto insurance short term health insurance motor insurance cheap online car insurance online motor insurance quotes car insurance california buycarinsurance online vehicle insurance free car insurance quotes landlord insurance health insurance for children motorbike insurance monthly car insurance car insurance usa car insurance reviews car insurance renewal quotes vehicle insurance health insurance rates term life insurance quotes vehicle insurance quotes car insurance compare motor vehicle insurance best car insurance motor insurance online quote car insurance online quote life insurance online supplemental health insurance best car insurance rates car insurance discounts motor vehicle insurance quotes auto insurance cheap travel insurance bike insurance travel medical insurance buy car insurance online online motor insurance travel insurance quote get a quote for car insurance health insurance agent car insurance companies cheap car insurance companies travel insurance annual travel insurance commercial vehicle insurance permanent life insurance medical insurance quotes online car insurance cheap car insurance quotes car insurance online quote insurance online level term life insurance health insurance comparison how much is car insurance travel health insurance pet health insurance quotes on cars health ins travel insurance uk quote for car insurance get insurance quote online disability insurance quote temporary health insurance temporary insurance rental car insurance cheap health insurance auto insurance compare third party car insurance buy health insurance auto insurance quotes cheap insurance companies best term life insurance personal health insurance online quote insurance car insurance premium health insurance policies quotes for cars whole life insurance credit insurance cheap van insurance cheap term life insurance cheap motorcycle insurance compare life insurance car insurance cover health insurance motorcycle insurance short term car insurance health insurance coverage insurance qoute cheap life insurance house insurance quote car insurance uk health insurance companies cigna health insurance cheap insurance cheap car insurance uk compare health insurance car insurance for young drivers short term insurance online health insurance caravan insurance life insurance comparison direct insurance health insurance plans motor insurance online car insurance estimator accident insurance home insurance quotes nj car insurance new car insurance private medical insurance home insurance car insurance brokers car insurance rates commercial insurance health insurance quotes motor insurance companies which car insurance car quotes online online auto insurance flood insurance cheap auto insurance quotes car insurance agencies business health insurance term life insurance truck insurance professional indemnity insurance life insurance car insurance policy long term care insurance drive insurance buy insurance car ins motorcycle insurance quote critical illness insurance term insurance student health insurance home insurance comparison insurance rates insurance cover holiday insurance insurance sites online vehicle insurance quotes company website home insurance rates compare insurance buy insurance online affordable medical insurance car insurance coverage product liability insurance home contents insurance buy life insurance renters insurance group health insurance family health insurance motor insurance quote online mortgage insurance best home insurance personal insurance medical insurance property insurance life insurance agent group insurance aetna health insurance cheap medical insurance liability insurance rental insurance life insurance policy group life insurance general liability insurance insurance quotes online all car insurance companies best health insurance insurance plans life insurance for seniors van insurance website quote universal life insurance building insurance co insurance insurance car car insurance prices disability insurance insurance vehicle cheap vehicle insurance senior life insurance medical insurance plans insurance health house insurance life insurance quotes car quotes cheap home insurance business insurance com bank credit card lowest credit card eligibility no fee credit cards best credit card compare how can i apply for credit card business credit cards cheapest credit card company credit card corporate credit card apply for a credit card online 0 apr credit cards how can i get credit card get a credit card open credit card usa credit card instant credit card approval store credit cards credit card shopping airline miles credit card frequent flyer credit cards hotel credit cards best credit card deals compare credit miles credit card credit card consolidation college student credit cards how do i apply for a credit card gold credit card how to open credit card apply for credit card eligibility for credit card credit card verification credit card offers online credit card application form which credit card to apply how can i get a credit card credit card online apply credit cards uk 0 credit cards looking for credit card offers credit card information bank credit card application travel credit cards what is a credit card credit card sign up master credit card cash back cards platinum credit card compare visa cards credit bank credit card no interest credit cards cheap credit cards 0 credit card offers online credit new credit cards application of credit card how to apply for credit card apply card credit online credit card deals premier credit card mastercard credit card how to get credit card apply credit card credit card application credit companies creditcard cash back credit cards airline credit cards cash credit card credit card rates student credit cards apply credit card online how to apply credit card interest free credit card secured credit card best travel credit card capital one credit card online credit card application credit cards with no annual fee new credit card offers apply online credit card credit card apply online best rewards credit card city credit card how to get a credit card credit card counseling rebate credit card mastercard debit card credit card debt best credit cards to apply for best credit cards apply for credit card online credit card apply how to apply for a credit card apply for new credit card credit card rebate best credit card comparison apply for visa card online cim credit card good credit cards credit card cash back best cash back credit cards mastercard credit card application credit card checker credit card mastercard instant credit card card compare credit card rewards programs compare the best credit cards apply visa card cash rebate credit card bankruptcy credit cards card offers instant approval credit cards credit card online application credit cards for students how to sign up for credit card uk credit cards credit card account about credit card visa card apply online credit card compare site secured mastercard visa card application credit card rewards credit rating how can we get credit card visa credit card rewards card online credit card processing capital credit card credit card visa consolidate credit cards credit card processing credit card reviews apply new credit card business credit card application credit cards with cash back credit card reader credit card instant approval online apply credit card bad credit credit cards credit card selection online visa card pay with credit card credit card charges visa or mastercard credit card machine apply a credit card small business credit cards prepaid debit cards visa debit card mbna credit card credit card terminal card credit application credit card generator credit card balance credit card numbers credit card transfer credit card interest rates credit card interest gold card credit card online best rate credit cards credit card low interest visa card online online credit card how to apply a credit card 0 interest credit cards debit card the cheapest car insurance cost of car insurance best car insurance quotes insurance auto insurance quotes car get car insurance quotes online car insurance agent instant car insurance quote car insurance websites direct car insurance insure a car motor car insurance quote cheap car insurance online quotes for car insurance car insurers commercial car insurance motor insurance quote car insurance quotes online get a quote online international health insurance compare car insurance quotes insurance for car compare car insurance car insurance buy life insurance online compare auto insurance international medical insurance general car insurance cheap motor insurance low car insurance car insurance comparison company car insurance budget car insurance private health insurance online quote car insurance cheap motor car insurance car insurance for new drivers cheap car insurance quotes online online car insurance quotes get car insurance quotes car insurance quotes comparison motor car insurance car insurance quotes car insurance cheap comprehensive car insurance best auto insurance short term health insurance motor insurance cheap online car insurance online motor insurance quotes car insurance california buycarinsurance online vehicle insurance free car insurance quotes landlord insurance health insurance for children motorbike insurance monthly car insurance car insurance usa car insurance reviews car insurance renewal quotes vehicle insurance health insurance rates term life insurance quotes vehicle insurance quotes car insurance compare motor vehicle insurance best car insurance motor insurance online quote car insurance online quote life insurance online supplemental health insurance best car insurance rates car insurance discounts motor vehicle insurance quotes auto insurance cheap travel insurance bike insurance travel medical insurance buy car insurance online online motor insurance travel insurance quote get a quote for car insurance health insurance agent car insurance companies cheap car insurance companies travel insurance annual travel insurance commercial vehicle insurance permanent life insurance medical insurance quotes online car insurance cheap car insurance quotes car insurance online quote insurance online level term life insurance health insurance comparison how much is car insurance travel health insurance pet health insurance quotes on cars health ins travel insurance uk quote for car insurance get insurance quote online disability insurance quote temporary health insurance temporary insurance rental car insurance cheap health insurance auto insurance compare third party car insurance buy health insurance auto insurance quotes cheap insurance companies best term life insurance personal health insurance online quote insurance car insurance premium health insurance policies quotes for cars whole life insurance credit insurance cheap van insurance cheap term life insurance cheap motorcycle insurance compare life insurance car insurance cover health insurance motorcycle insurance short term car insurance health insurance coverage insurance qoute cheap life insurance house insurance quote car insurance uk health insurance companies cigna health insurance cheap insurance cheap car insurance uk compare health insurance car insurance for young drivers short term insurance online health insurance caravan insurance life insurance comparison direct insurance health insurance plans motor insurance online car insurance estimator accident insurance home insurance quotes nj car insurance new car insurance private medical insurance home insurance car insurance brokers car insurance rates commercial insurance health insurance quotes motor insurance companies which car insurance car quotes online online auto insurance flood insurance cheap auto insurance quotes car insurance agencies business health insurance term life insurance truck insurance professional indemnity insurance life insurance car insurance policy long term care insurance drive insurance buy insurance car ins motorcycle insurance quote critical illness insurance term insurance student health insurance home insurance comparison insurance rates insurance cover holiday insurance insurance sites online vehicle insurance quotes company website home insurance rates compare insurance buy insurance online affordable medical insurance car insurance coverage product liability insurance home contents insurance buy life insurance renters insurance group health insurance family health insurance motor insurance quote online mortgage insurance best home insurance personal insurance medical insurance property insurance life insurance agent group insurance aetna health insurance cheap medical insurance liability insurance rental insurance life insurance policy group life insurance general liability insurance insurance quotes online all car insurance companies best health insurance insurance plans life insurance for seniors van insurance website quote universal life insurance building insurance co insurance insurance car car insurance prices disability insurance insurance vehicle cheap vehicle insurance senior life insurance medical insurance plans insurance health house insurance life insurance quotes car quotes cheap home insurance business insurance com bank credit card lowest credit card eligibility no fee credit cards best credit card compare how can i apply for credit card business credit cards cheapest credit card company credit card corporate credit card apply for a credit card online 0 apr credit cards how can i get credit card get a credit card open credit card usa credit card instant credit card approval store credit cards credit card shopping airline miles credit card frequent flyer credit cards hotel credit cards best credit card deals compare credit miles credit card credit card consolidation college student credit cards how do i apply for a credit card gold credit card how to open credit card apply for credit card eligibility for credit card credit card verification credit card offers online credit card application form which credit card to apply how can i get a credit card credit card online apply credit cards uk 0 credit cards looking for credit card offers credit card information bank credit card application travel credit cards what is a credit card credit card sign up master credit card cash back cards platinum credit card compare visa cards credit bank credit card no interest credit cards cheap credit cards 0 credit card offers online credit new credit cards application of credit card how to apply for credit card apply card credit online credit card deals premier credit card mastercard credit card how to get credit card apply credit card credit card application credit companies creditcard cash back credit cards airline credit cards cash credit card credit card rates student credit cards apply credit card online how to apply credit card interest free credit card secured credit card best travel credit card capital one credit card online credit card application credit cards with no annual fee new credit card offers apply online credit card credit card apply online best rewards credit card city credit card how to get a credit card credit card counseling rebate credit card mastercard debit card credit card debt best credit cards to apply for best credit cards apply for credit card online credit card apply how to apply for a credit card apply for new credit card credit card rebate best credit card comparison apply for visa card online cim credit card good credit cards credit card cash back best cash back credit cards mastercard credit card application credit card checker credit card mastercard instant credit card card compare credit card rewards programs compare the best credit cards apply visa card cash rebate credit card bankruptcy credit cards card offers instant approval credit cards credit card online application credit cards for students how to sign up for credit card uk credit cards credit card account about credit card visa card apply online credit card compare site secured mastercard visa card application credit card rewards credit rating how can we get credit card visa credit card rewards card online credit card processing capital credit card credit card visa consolidate credit cards credit card processing credit card reviews apply new credit card business credit card application credit cards with cash back credit card reader credit card instant approval online apply credit card bad credit credit cards credit card selection online visa card pay with credit card credit card charges visa or mastercard credit card machine apply a credit card small business credit cards prepaid debit cards visa debit card mbna credit card credit card terminal card credit application credit card generator credit card balance credit card numbers credit card transfer credit card interest rates credit card interest gold card credit card online best rate credit cards credit card low interest visa card online online credit card how to apply a credit card 0 interest credit cards debit card

Cara mengkoneksikan device android dengan Database MySQL

Hey guys, bagaimana kabarmu .. ??, penulis berharap teman2 semua masih semangat untuk belajar Pemrograman Android..hehehe ..

Dalam posting ini, penulis ingin berbagi tentang Cara membuat aplikasi client-server berbasis Android dengan MySQL server DBMS.

Nah, dalam tutorial ini kita perlu script PHP untuk menghubungkan antara perangkat android dengan MySQL. orang ok tanpa basa-basi cukup ikuti langkah berikut:

1. Buat database baru dengan nama "akademis" dan membuat tabel baru dengan nama "MHS" dengan struktur sebagai berikut seperti yang ditunjukkan di bawah ini:

Cara mengkoneksikan device android dengan Database MySQL

2. Buat file php dan simpan dengan nama "koneksi.php" dan menyimpan file php di server database Anda, jika Anda menggunakan toko XAMPP di direktori C: \ xampp \ htdocs \ dan jika Anda menggunakan WAMP toko di direktori C: \ wamp \ www \


Script PHP nya sebagai berikut:


<?php

$nobp=$_POST['nobp'];
$nama=$_POST['nama'];
$jurusan=$_POST['jurusan'];
$konek=mysql_connect("localhost","root","");
mysql_select_db("akademik");
$query="insert into mhs values('$nobp','$nama','$jurusan')";
$result=mysql_query($query);

?>


Membuat script php pada diatas dan menyimpannya di database server , Sekarang buatlah project android baru dengan nama Prjakademik dengan ketentuan seperti dibawah ini:


Cara mengkoneksikan device android dengan Database MySQL

3 . Desain layoutnya dengan coding main.xml seperti berikut:

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:orientation="vertical"
    android:layout_width="fill_parent"
    android:layout_height="fill_parent">


<EditText

android:layout_height="wrap_content"
android:layout_width="fill_parent"
android:id="@+id/Enobp"
android:hint="Masukan NoBP"/>
<EditText
android:layout_height="wrap_content"
android:layout_width="fill_parent"
android:id="@+id/Enama"
android:hint="Masukan Nama"/>
<EditText
android:layout_height="wrap_content"
android:layout_width="fill_parent"
android:id="@+id/Ejurusan"
android:hint="Masukan Jurusan"/>
<Button
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:id="@+id/simpan"
android:text="Simpan"/>
</LinearLayout>


Coding Script di atas akan menghasilkan sebuah layout pada gambar dibawah ini :


Cara mengkoneksikan device android dengan Database MySQL


4 . sekarang beralih ke package javanya dan buat class baru dengan cara klik kanan pada nama paketnya -> new -> class seperti gambar dibawah ini:

Cara mengkoneksikan device android dengan Database MySQL

5. Buat kelas baru dengan nama kelas CustomHttpClient dan mengetik kode berikut untuk kelas:

package com.fikri;
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.net.URI;
import java.util.ArrayList;
import org.apache.http.HttpResponse;
import org.apache.http.NameValuePair;
import org.apache.http.client.HttpClient;
import org.apache.http.client.entity.UrlEncodedFormEntity;
import org.apache.http.client.methods.HttpGet;
import org.apache.http.client.methods.HttpPost;
import org.apache.http.conn.params.ConnManagerParams;
import org.apache.http.impl.client.DefaultHttpClient;
import org.apache.http.params.HttpConnectionParams;
import org.apache.http.params.HttpParams;
public class CustomHttpClient {
public static final int HTTP_TIMEOUT=30*1000;
private static HttpClient mHttpClient;


private static HttpClient geHttpClient() {

       if (mHttpClient==null){
              mHttpClient=new DefaultHttpClient();
              final HttpParams params=mHttpClient.getParams();
              HttpConnectionParams.setConnectionTimeout(params, HTTP_TIMEOUT);
              HttpConnectionParams.setSoTimeout(params, HTTP_TIMEOUT);
              ConnManagerParams.setTimeout(params, HTTP_TIMEOUT);
       }
       return mHttpClient;
}
public static String executeHttpPost(String url,ArrayList<NameValuePair>posparameter)throws Exception {
       BufferedReader in=null;
       try{
              HttpClient client=geHttpClient();
              HttpPost request=new HttpPost(url);
              UrlEncodedFormEntity formEntity=new UrlEncodedFormEntity(posparameter);
              request.setEntity(formEntity);
              HttpResponse respon=client.execute(request);
              in=new BufferedReader(new InputStreamReader(respon.getEntity().getContent()));
              StringBuffer sb=new StringBuffer("");
              String line="";
              String NL=System.getProperty("line.separator");
              while ((line=in.readLine())!=null) {
                     sb.append(line+NL);
              }
              in.close();
              String result=sb.toString();
              return result;
       }finally{
              if(in != null){
                     try{
                           in.close();
                     }catch(IOException e){
                           e.printStackTrace();
                     }
              }
       }
      
}
public static String executeHttpGet(String url)throws Exception{
       BufferedReader in=null;
       try{
              HttpClient client=geHttpClient();
              HttpGet request=new HttpGet();
              request.setURI(new URI(url));
              HttpResponse respon=client.execute(request);
              in=new BufferedReader(new InputStreamReader(respon.getEntity().getContent()));
              StringBuffer sb=new StringBuffer("");
              String line="";
              String NL=System.getProperty("line.separator");
              while ((line=in.readLine())!=null) {
                     sb.append(line + NL);     
              }
              in.close();
              String result=sb.toString();
              return result;
       }finally{
              if(in != null){
                     try{
                           in.close();
                     }catch(IOException e){
                           e.printStackTrace();
                     }
              }
       }
      
}
}


6 . Pada aktivitas1.java ketikan coding berikut:


package com.fikri;


import java.io.IOException;

import java.util.ArrayList;


import org.apache.http.NameValuePair;

import org.apache.http.message.BasicNameValuePair;


import android.R.string;

import android.app.Activity;
import android.os.Bundle;
import android.view.View;
import android.view.View.OnClickListener;
import android.webkit.WebChromeClient.CustomViewCallback;
import android.widget.Button;
import android.widget.EditText;
import android.widget.Toast;


public class aktivitas1 extends Activity {

    /** Called when the activity is first created. */
       EditText nobp,nama,jur;
       Button sim;
      
    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.main);
        nobp=(EditText)findViewById(R.id.Enobp);
        nama=(EditText)findViewById(R.id.Enama);
        jur=(EditText)findViewById(R.id.Ejurusan);
        sim=(Button)findViewById(R.id.simpan);
        sim.setOnClickListener(new OnClickListener() {
                    


                     public void onClick(View v) {

                           // TODO Auto-generated method stub
                           ArrayList<NameValuePair> postparameter=new ArrayList<NameValuePair>();
                           postparameter.add(new BasicNameValuePair("nobp", nobp.getText().toString()));
                           postparameter.add(new BasicNameValuePair("nama", nama.getText().toString()));
                           postparameter.add(new BasicNameValuePair("jurusan", jur.getText().toString()));
                           String respon=null;
                           try{
                                  respon=CustomHttpClient.executeHttpPost("http://10.0.2.2/android/koneksi.php",postparameter);
                                  String res=respon.toString();
                                  res=res.trim();
                                  res=res.replaceAll("\\s", "");
                                  if(res.equals("1"))
                                         Toast.makeText(getApplicationContext(),"Data Sudah Tersimpan" , Toast.LENGTH_LONG).show();
                                  else
                                         Toast.makeText(getApplicationContext(),"Data Sudah Tersimpan Ke Server" , Toast.LENGTH_LONG).show();
                           }catch(Exception e){
                                  Toast.makeText(getApplicationContext(), "Error :"+ e.toString(), Toast.LENGTH_LONG).show();
                           }
                          
                     }
              }
        );
       
    }
}


7 . Ubah Coding AndroidManifest.xml menjadi seperti berikut:


<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
      package="com.fikri"
      android:versionCode="1"
      android:versionName="1.0">
    <application android:icon="@drawable/icon" android:label="@string/app_name">
        <activity android:name=".aktivitas1"
                  android:label="@string/app_name">
            <intent-filter>
                <action android:name="android.intent.action.MAIN" />
                <category android:name="android.intent.category.LAUNCHER" />
            </intent-filter>
        </activity>


    </application>

    <uses-sdk android:minSdkVersion="8" />
    <uses-permission android:name="android.permission.INTERNET"/>
</manifest>


8 . silahkan running programnya maka akan terlihat hasilnya seperti gambar berikut:


Cara mengkoneksikan device android dengan Database MySQL

9. Isi data dan klik tombol simpan, data akan dimasukkan database yang Ke di inputkan Server seperti yang ditunjukkan di bawah ini:

Cara mengkoneksikan device android dengan Database MySQL

di sini pertama dan mudah-mudahan tutorial ini bermanfaat dan terima kasih untuk mengunjungi.

Baca juga artikel terbaru : Cara membuat Aplikasi Android tanpa koding

BERITA LENGKAP DI HALAMAN BERIKUTNYA

Halaman Berikutnya

Subscribe to receive free email updates:

0 Response to "Cara mengkoneksikan device android dengan Database MySQL"

Post a Comment

close
==[ Klik disini 1X ] [ Close ]==