How to get data from MySQL database and list in the ListView
<p>I've seen numerous questions/tutorials about this, but all of them either use some kind of premade database or work with JSON.</p>

<p>I already created a database and a table with simlpe data that resides on my <code>MySQL</code> server, which is running separately as a service on my development machine.</p>

<p>I want to pull the data from that table and list it in the ListView(MainActivity) of my Andoird app when it's launched(onCreate).</p>

<p>At the moment I'm using a premade list of car names.</p>

<p><strong>Cars table</strong>(in mydb database)</p>

<p><code>id</code>, <code>name</code>, <code>model</code>, <code>year</code>, <code>vin</code>, <code>km</code>, <code>price</code></p>

<p><strong>MainActivity.java</strong></p>

<pre><code>package com.example.myfirstproject;

import android.app.Activity;
import android.content.Intent;
import android.os.Bundle;
import android.view.Menu;
import android.view.View;
import android.widget.AdapterView;
import android.widget.AdapterView.OnItemClickListener;
import android.widget.ArrayAdapter;
import android.widget.ListAdapter;
import android.widget.ListView;

public class MainActivity extends Activity implements OnItemClickListener  {

    protected String[] cars =  {"BMW", "Audi", "VW", "Ford", "Subaru"};

    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);
        ListAdapter adapter = new ArrayAdapter&lt;String&gt;(this, android.R.layout.simple_list_item_1, cars);
        ListView carsList = (ListView) findViewById(R.id.listCars);
        carsList.setAdapter(adapter);
        ListView list = (ListView) findViewById(R.id.listCars);
        list.setOnItemClickListener(this);
    }

    @Override
    public boolean onCreateOptionsMenu(Menu menu) {
        getMenuInflater().inflate(R.menu.activity_main, menu);
        return true;
    }

    public void onItemClick(AdapterView&lt;?&gt; arg0, View arg1, int arg2, long arg3) {
        Intent intent = new Intent(this, DetailsActivity.class);
        startActivity(intent);
    }
}
</code></pre>
