Access External Database on an Android App
Why Stack Overflow recommends it
Stack Overflow users cite it as the tutorial they followed when connecting an Android app to a remote or local MySQL database through PHP and JSON, usually while asking about errors or next steps.
Recommended by 0 people across 0 different months, 2014 to 2014.
What it is
A 2014 tutorial by Taseen Amin showing how to read data from an external MySQL database in an Android app. It uses PHP scripts that return JSON, with AsyncTask handling the network call off the main thread, and links the full source code.
What people said
Cites user3241507 · 2014-05 · Stack Overflow · on “Null Pointer exception on JSON.getString JSONObject”
I am trying to get the username from a database using PHP on android. I have it set up on my localhost. the output on localhost is: [{"id":"1","username":"Josh","password":"pass"}] The PHP is: <?php $con = $con = mysql_connect("localhost", "root", "root"); if (!$con) { die('Could not connect: ' . mysql_error()); } mysql_select_db("natter", $con); $result = mysql_query("SELECT * FROM users"); while($row = mysql_fetch_assoc($result)) { $output[] = $row; } print(json_encode($output)); mysql_close($con); The java is: public void setTextToTextView(JSONArray jsonArray) { String s = ""; for (int i = 0; i < jsonArray.length(); i++) { JSONObject json = null; try { json = jsonArray.getJSONObject(i); s
Cites Kamal · 2014-06 · Stack Overflow · on “Android: How to put each tuple returned from a SQL database as text on a button?”
so I am making this app which currently connects to an external SQL database with a list of item names (I use php and json for this), and it displays these names as a textView. I followed this tutorial to learn this: [this video] However, what I really want to do is have the app have a button for EACH of the item names. Is there a way to make my app such that for each item name it pulls from the database, it creates a button, with the item's name as the text on that button?
Cites David · 2014-09 · Stack Overflow · on “Connect app to local mysql database”
I'm using this video [this video] to try and connect an android app to a locally hosted MySQL database. The php script doesn't seem to be the issue as it works fine locally (through internet explorer) and I keep on receiving a null pointer exception causing the app to crash. The main activity protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_main); this.responseTextView = (TextView) this.findViewById(R.id.responseTextView); new GetAllCustomerTask().execute(new ApiConnector()); } public void setTextToTextView(JSONArray jsonArray) { String s = ""; for(int i=0; i<jsonArray.length();i++){ JSONObject json = null; try { json = json