Possibly a noob question but hopefully I can learn how to do this for the future as well.
I've connected to a mysql database on my server, connects fine, everything works. The problem is I don't know how to get that data into a table for me to use in the layout (Is a tablelayout the best way? I don't want it to fill up an entire layout, I want to be able to add text above the table and below). The code below prints the data into the logcat. You can see for yourself, it's quite basic. I've been learning to do this via various tutorials. Obviously it's not what I want though.
Does anyone have any advice on what code I should be putting here so that I can actually use my data once the app has received it. It's already in the JSON format as you can see below. The code below works, it's just not what I want it to do. The tutorials I've seen have implemented the HTTP connection and use ArrayAdaptors together but I've already done the HTTP POST bit and don't want to change it since it took me ages.
// PARSE STRING
try {
jArray = new JSONArray(result);
JSONObject json_data = null;
System.out.println("Length " + jArray.length());
Log.d("DB", "Length " + jArray.length());
for (int i = 0; i < jArray.length(); i++) {
json_data = jArray.getJSONObject(i);
drivername = json_data.getString("Driver_full_name");
drivesfor = json_data.getString("Drives_for");
System.out.println(drivername + "&" + drivesfor);
}
} catch (JSONException e1) {
Log.d("DB", "Error somewhere");
CurrentSeasonDrivers.this.runOnUiThread(new Runnable() {
public void run() {
Toast.makeText(CurrentSeasonDrivers, "Could not convert data to string", Toast.LENGTH_LONG).show(); } });
}
Any advice is appreciated! My full code including the HTTP connection to show you how I've set things up: http://pastebin.com/MsKc1xPg