How to insert data into MySQL Server using ArrayAdapter (Java)?
<p>I am new in android development, I want to insert call log details in MySQL database, here I have created simple <code>ArrayAdapter</code> that's not getting set in listview and second thing is, how to insert data in MySQL server.</p>

<p>Here is my java code</p>

<pre><code>public class MainActivity extends Activity {
ListView listView;
@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_main);
    listView = (ListView) findViewById(R.id.lv);
    getCallDetails();
}
private void getCallDetails()
{
    StringBuffer sb = new StringBuffer();
    String strOrder = android.provider.CallLog.Calls.DATE + " DESC";
    Cursor managedCursor = managedQuery(CallLog.Calls.CONTENT_URI, null,null, null, strOrder);
    int number1 = managedCursor.getColumnIndex(CallLog.Calls.NUMBER);
    int type1 = managedCursor.getColumnIndex(CallLog.Calls.TYPE);
    int duration1 = managedCursor.getColumnIndex(CallLog.Calls.DURATION);
    sb.append("Call Log :");
    while (managedCursor.moveToNext())
    {
        final String number = managedCursor.getString(number1);
        final String type2 = managedCursor.getString(type1);
        final String date = managedCursor.getString(managedCursor.getColumnIndexOrThrow("date")).toString();
        java.util.Date date1 = new java.util.Date(Long.valueOf(date));
        final String duration = managedCursor.getString(duration1);
        String type = null;
        final String fDate = date1.toString();
        int callcode = Integer.parseInt(type2);
        switch (callcode)
        {
            case CallLog.Calls.OUTGOING_TYPE:
                type = "Outgoing";
                break;
            case CallLog.Calls.INCOMING_TYPE:
                type = "Incoming";
                break;
            case CallLog.Calls.MISSED_TYPE:
                type = "Missed";
                break;
        }
        List&lt;DataBean&gt; DataBeanList = new  ArrayList&lt;DataBean&gt;();
        DataBean dataBean = new DataBean(number, type, fDate, duration);
        DataBeanList.add(dataBean);
        Log.d("tag", DataBeanList.toString());
    }
    managedCursor.close();
    ArrayAdapter&lt;String&gt; arrayAdapter = new ArrayAdapter&lt;String&gt;(this,android.R.layout.simple_list_item_1,android.R.id.text1);
    listView.setAdapter(arrayAdapter);
   }
 }
</code></pre>

<p>Here is my php script.........</p>

<pre><code> &lt;?php 
 //Importing our db connection script
 require_once('connect.php');

if($_SERVER['REQUEST_METHOD']=='POST'){
//Getting values
$number = $_POST['number'];
$duration = $_POST['duration'];
$type = $_POST['type'];
$time = $_POST['time'];

//Creating an sql query
$sql = "INSERT INTO call_detail (number,duration,type,time) VALUES   ('$number','$duration','$type','$time')";

    //Executing query to database
    if(mysqli_query($con,$sql)){
        echo 'Entry Added Successfully';
    }else{
        echo 'Could Not Add Entry';
    }

//Closing the database 
mysqli_close($con);
 }
</code></pre>