Android MySQL → Android MySQL – Camposha

Android MySQL

Android MySQL

Android MySQL

Android MySQL

Android PHP MySQL 

MySQL is our database while PHP is the server side language we use. The client code is for android and is written in this case in either Java or Kotlin.

 

Let’s start by a brief introduction before we look at various examples.

What is a Database?

A database, generally speaking, refers to any organized collection of data

There are several types of databases:

  1. Flat file databases ― these store data sequentially, often in plain text files.
  2. Hierarchical databases ― these organize data in parent/child relationships.
  3. Key-value/document-oriented databases ― these store free-form data indexed
    by a key or hash value.
  4. Relational databases ― these organize data in rows and tables. This is the most popular and is what we use in most of our examples.

What is MySQL ?

MySQL is an open source, multithreaded, relational database management system created
by Michael “Monty” Widenius in 1995.

Many businesses these days develop and maintain custom software with MySQL. Additionally, majority of the most popular websites(e.g Wikipedia) and software use MySQL for their database.

One of the most prominent features of MySQL is its speed and scalability. Together with MariaDB, MySQL’s identical twin brother/sister, tends of thousands of rows and billions of rows of data can efficiently be handled.

However, you can also use MySQL for small amounts of data, like we will do to store our PDF documents in this android pdf viewer app we will create.

Why do Alot of People Choose MySQL?

There are many RDBMS(Relational Database Management System) databases. However MySQL is the most popular.

This is because of the following factors:

  1. Speed. MySQL is fast. Its developers claim that MySQL is about the fastest database system you can get.You can investigate this claim by visiting here, a performance-comparison page on the MySQL Web site.
  2. Ease of use. Even though MySQL is highly performant, it’s relative a simple database system. Setting it up and Administering it is much less complex than other large systems.
  3. Query language support. MySQL also provides support for SQL(Structured Query Language). SQL is the standard language of choice for almost all modern database systems.
  4. Capability. The MySQL server is multi-threaded. This implies that many clients can connect to it at the same time. Each client can use multiple databases simultaneously.
  5. Connectivity and security. MySQL is fully networked, and databases can be accessed from anywhere on the Internet. Hence you can share your data with anyone, anywhere. But MySQL has access control so that one person who shouldn’t see
    another’s data cannot.To provide additional security, MySQL supports encrypted connections using the Secure Sockets Layer (SSL) protocol.
  6. Availability and cost. MySQL is an Open Source project available under multiple licensing terms. First, it is available under the terms of the GNU General Public
    License (GPL).This means that MySQL is available without cost for most in-house uses. Second, for organizations that prefer or require formal arrangements or that do not want to be bound by the conditions of the GPL, commercial licenses are available.

What is MySQLi?

MySQLi is a PHP extension which allows us to access the functionality provided by MySQL 4.1 and above.

As an extension, mysqli exposes APIs to the PHP programmer, to allow us work with MySQL database programmatically.

Normally there are three ways(APIs) of working with MySQL from database:

  1. PHP MySQLi extension.
  2. PHP MySQL extension.
  3. PHP Data Objects(PDO).

In this class we will use the most commonly used API which is mysqli.

Advantages of MySQLi

MySQLi is the most popular API for working with MySQL database because of the following reasons:

  1. Provision of both Object Oriented and Procedural Interfaces.
  2. Embedded Server support.
  3. Support for Prepared Statements.
  4. Ability to use Multiple Statements.
  5. Transactions support.

etc

You can find more information about mysqli here.

 

(1) Comment

  • Mehdi June 18, 2019 @ 12:59 pm

    hi
    I used this course code in android studio.
    In MyActivity.java these two line on word “Sender” make error.
    Sender s = new Sender(MainActivity.this,urlAddress, nameTxt, posTxt, teamTxt);
    ((Sender) s).execute();
    Could you please help me?
    thanks

    and the error message is “error: cannot find symbol class Sender”

    The “Sender” class is follow
    import android.app.ProgressDialog;
    import android.content.Context;
    import android.os.AsyncTask;
    import android.widget.EditText;
    import android.widget.Toast;

    import java.io.BufferedReader;
    import java.io.BufferedWriter;
    import java.io.IOException;
    import java.io.InputStreamReader;
    import java.io.OutputStream;
    import java.io.OutputStreamWriter;
    import java.net.HttpURLConnection;

    public class Sender extends AsyncTask {

    Context c;
    String urlAddress;
    EditText nameTxt, postTxt, teamTxt;

    String name, pos, team;

    ProgressDialog pd;

    public Sender(Context c, String urlAddress, EditText…editTexts) {
    this.c = c;
    this.urlAddress = urlAddress;

    this.nameTxt = editTexts[0];
    this.postTxt = editTexts[1];
    this.teamTxt = editTexts[2];

    name = nameTxt.getText().toString();
    pos = postTxt.getText().toString();
    team = teamTxt.getText().toString();

    }

    protected void onPreExecute() {
    super.onPreExecute();

    pd = new ProgressDialog(c);
    pd.setTitle(“Send”);
    pd.setMessage(“Sending …. Please wait”);
    pd.show();

    }

    @Override
    protected String doInBackground(Void… parms) {
    return this.send();
    }

    @Override
    protected void onPostExecute(String response) {

    super.onPostExecute(response);

    pd.dismiss();

    if (response != null) {
    Toast.makeText(c, response, Toast.LENGTH_SHORT).show();

    nameTxt.setText(“”);
    postTxt.setText(“”);
    teamTxt.setText(“”);

    } else {
    Toast.makeText(c, “Unsuccessful” + response, Toast.LENGTH_SHORT).show();

    }
    }

    private String send() {
    HttpURLConnection con = com.tutorials.hp.androidmdmysqlsave.mMySQL.Connector.connect(urlAddress);
    if (con == null) {
    return null;

    }
    try {
    OutputStream os = con.getOutputStream();

    BufferedWriter bw = new BufferedWriter(new OutputStreamWriter(os, “UTF-8”));
    bw.write(new com.tutorials.hp.androidmdmysqlsave.mMySQL.DataPackager(name, pos, team).packData());

    bw.flush();
    bw.close();
    os.close();

    int responseCode = con.getResponseCode();

    if (responseCode == con.HTTP_OK) {
    BufferedReader br = new BufferedReader(new InputStreamReader(con.getInputStream()));
    StringBuffer response = new StringBuffer();

    String line;

    while ((line = br.readLine()) != null) {
    response.append(line);
    }

    br.close();
    return response.toString();
    } else {

    }

    } catch (IOException e) {
    e.printStackTrace();
    }
    return null;
    }
    }

    Reply

Leave a Reply

Your email address will not be published. Required fields are marked *

Price

Free

Rating

Not enough ratings to display
X