Get and show data from MySQL of a single user in the Android appWhich MySQL data type to use for storing boolean valuesShould I use the datetime or timestamp data type in MySQL?How to get a list of user accounts using the command line in MySQL?Static way to get 'Context' in Android?How do I get a YouTube video thumbnail from the YouTube API?How do I pass data between Activities in Android application?Download a file with Android, and showing the progress in a ProgressDialogHow do I get extra data from intent on Android?Get current time and date on AndroidHow to get the sizes of the tables of a MySQL database?

Possible nonclassical ion from a bicyclic system

Is floating in space similar to falling under gravity?

Can a rogue effectively triple their speed by combining Dash and Ready?

Mother abusing my finances

Where can I find the list of all tendons in the human body?

Expenditure in Poland - Forex doesn't have Zloty

Thousands and thousands of words

How was Apollo supposed to rendezvous in the case of a lunar abort?

Select row of data if next row contains zero

How to prevent bad sectors?

How can I offer a test ride while selling a bike?

How can I grammatically understand "Wir über uns"?

Will My Circuit Work As intended?

What does the behaviour of water on the skin of an aircraft in flight tell us?

Could I be denied entry into Ireland due to medical and police situations during a previous UK visit?

What is the indigenous Russian word for a wild boar?

What is game ban VS VAC ban in steam?

Geometry affects line breaking

Differences between “pas vrai ?”, “c’est ça ?”, “hein ?”, and “n’est-ce pas ?”

Can a non-EU citizen travel within the Schengen area without identity documents?

Understanding STM32 datasheet regarding decoupling capacitors

How to properly maintain eye contact with people that have distinctive facial features?

Asking bank to reduce APR instead of increasing credit limit

chmod would set file permission to 000 no matter what permission i try to set



Get and show data from MySQL of a single user in the Android app


Which MySQL data type to use for storing boolean valuesShould I use the datetime or timestamp data type in MySQL?How to get a list of user accounts using the command line in MySQL?Static way to get 'Context' in Android?How do I get a YouTube video thumbnail from the YouTube API?How do I pass data between Activities in Android application?Download a file with Android, and showing the progress in a ProgressDialogHow do I get extra data from intent on Android?Get current time and date on AndroidHow to get the sizes of the tables of a MySQL database?






.everyoneloves__top-leaderboard:empty,.everyoneloves__mid-leaderboard:empty,.everyoneloves__bot-mid-leaderboard:empty height:90px;width:728px;box-sizing:border-box;








0















I'm working on an Android app where I save the data in a MySQL database and then I have to display it in the TextView of the Android app.



When the user clicks on the 'Information' button he must view all his information.



The problem is that I don't understand how to do it, I tried to use the code of this tutorial "https://androidjson.com/android-php-insert-display-select-update-delete/", but the problem is that I don't I have a View list, I only have one button and I can't understand how to show the data of a single user.



The android app it shows nothing, the data does not arrive.



I also tried to passed the user's id in the previous activity, but then I don't know how to show that user's data in the next activity.



My table in MySQL is called Restaurants and has 11 fields.



  • idR

  • LocalName

  • MediumPrize

  • Country

  • Region

  • Province

  • Cap

  • Address

  • Email

  • Telephone Number

My php code is :



<?php

if($_SERVER['REQUEST_METHOD']=='POST')

include 'config.php';

$idR= r285602265407430;

// Create connection
$conn = new mysqli($HostName, $HostUser, $HostPass, $DatabaseName);

if ($conn->connect_error)

die("Connection failed: " . $conn->connect_error);


$sql = "SELECT * FROM Ristoranti WHERE idR = '$idR'" ;

$result = $conn->query($sql);

if ($result->num_rows >0)


while($row[] = $result->fetch_assoc())

$tem = $row;

$json = json_encode($tem);

echo 'culo';



else
echo "No Results Found.";

echo $json;

$conn->close();

?>


My Java code is :



import android.app.ProgressDialog;
import android.content.Context;
import android.content.Intent;
import android.os.AsyncTask;
import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;
import android.view.View;
import android.widget.Button;
import android.widget.EditText;
import android.widget.TextView;

import org.json.JSONArray;
import org.json.JSONException;
import org.json.JSONObject;

import java.util.HashMap;

public class Modifica_info_base extends AppCompatActivity

HttpParse_info httpParse = new HttpParse_info();
ProgressDialog pDialog;


// Http Url For Filter Student Data from Id Sent from previous activity.
String HttpURL = "http://provaord.altervista.org/OrdPlace/InformazioniRistorante/filter_info_base.php";

String finalResult ;
HashMap<String,String> hashMap = new HashMap<>();
String ParseResult ;
HashMap<String,String> ResultHash = new HashMap<>();
String FinalJSonObject ;
String text;
TextView tNomeRistorante, tPrezzoMedio, tNazione, tRegione, tCitta, tProvincia, tCap, tIndirizzo, tEmail, tNumero;
String Nomeristorante, Prezzomedio, Nazione, Regione, Citta, Provincia, Cap, Indirizzo, Email, Numero;
Button UpdateButton;
String TempItem;
ProgressDialog progressDialog2;
EditText idR;

@Override
protected void onCreate(Bundle savedInstanceState)
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_modifica_info_base);

tNomeRistorante = (TextView)findViewById(R.id.textView_nome_ristorante);
tPrezzoMedio = (TextView)findViewById(R.id.textView_prezzo_medio);
tNazione = (TextView)findViewById(R.id.textView_nazione);
tRegione = (TextView)findViewById(R.id.textView_regione);
tCitta = (TextView)findViewById(R.id.textView_citta);
tProvincia = (TextView)findViewById(R.id.textView_provincia);
tCap = (TextView)findViewById(R.id.textView_cap);
tIndirizzo = (TextView)findViewById(R.id.textView_indirizzo);
tEmail = (TextView)findViewById(R.id.textView_email);
tNumero = (TextView)findViewById(R.id.textView_numero_telefono);

idR = (EditText)findViewById(R.id.editText5id);

UpdateButton = (Button)findViewById(R.id.button_modifica_info_base);

TempItem = getIntent().getStringExtra("ListViewValue");

final String text= idR.getEditableText().toString();

//Calling method to filter Student Record and open selected record.
HttpWebCall(text);

UpdateButton.setOnClickListener(new View.OnClickListener()
@Override
public void onClick(View v)
Intent intent = new Intent(Modifica_info_base.this,Messagge_ristoratore.class);

// Sending Student Id, Name, Number and Class to next UpdateActivity.
intent.putExtra("idR", String.valueOf(idR));
intent.putExtra("NomeLocale", Nomeristorante);
intent.putExtra("PrezzoMedio", Prezzomedio);
intent.putExtra("Nazione", Nazione);
intent.putExtra("Regione", Regione);
intent.putExtra("Citta", Citta);
intent.putExtra("Provincia", Provincia);
intent.putExtra("Cap", Cap);
intent.putExtra("Indirizzo", Indirizzo);
intent.putExtra("Email", Email);
intent.putExtra("Telefono", Numero);


startActivity(intent);

// Finishing current activity after opening next activity.
finish();

);



//Method to show current record Current Selected Record
public void HttpWebCall(final String PreviousListViewClickedItem)

class HttpWebCallFunction extends AsyncTask<String,Void,String>

@Override
protected void onPreExecute()
super.onPreExecute();

pDialog = ProgressDialog.show(Modifica_info_base.this,"Loading Data",null,true,true);


@Override
protected void onPostExecute(String httpResponseMsg)

super.onPostExecute(httpResponseMsg);

pDialog.dismiss();

//Storing Complete JSon Object into String Variable.
FinalJSonObject = httpResponseMsg ;

//Parsing the Stored JSOn String to GetHttpResponse Method.
new GetHttpResponse(Modifica_info_base.this).execute();



@Override
protected String doInBackground(String... params)

ResultHash.put("idR",params[0]);

ParseResult = httpParse.postRequest(ResultHash, HttpURL);

return ParseResult;



HttpWebCallFunction httpWebCallFunction = new HttpWebCallFunction();

httpWebCallFunction.execute(PreviousListViewClickedItem);



// Parsing Complete JSON Object.
private class GetHttpResponse extends AsyncTask<Void, Void, Void>

public Context context;

public GetHttpResponse(Context context)

this.context = context;


@Override
protected void onPreExecute()

super.onPreExecute();


@Override
protected Void doInBackground(Void... arg0)

try

if(FinalJSonObject != null)

JSONArray jsonArray = null;

try
jsonArray = new JSONArray(FinalJSonObject);

JSONObject jsonObject;

for(int i=0; i<jsonArray.length(); i++)

jsonObject = jsonArray.getJSONObject(i);

// Storing Student Name, Phone Number, Class into Variables.
Nomeristorante = jsonObject.getString("NomeLocale").toString() ;
Prezzomedio = jsonObject.getString("PrezzoMedio").toString() ;
Nazione = jsonObject.getString("Nazione").toString() ;
Regione = jsonObject.getString("Regione").toString() ;
Citta = jsonObject.getString("Citta").toString() ;
Provincia = jsonObject.getString("Provincia").toString() ;
Cap = jsonObject.getString("Cap").toString() ;
Indirizzo = jsonObject.getString("Indirizzo").toString() ;
Email = jsonObject.getString("Email").toString() ;
Numero = jsonObject.getString("Telefono").toString() ;



catch (JSONException e)
e.printStackTrace();



catch (Exception e)

e.printStackTrace();

return null;


@Override
protected void onPostExecute(Void result)


tNomeRistorante.setText(Nomeristorante);
tPrezzoMedio.setText(Prezzomedio);
tNazione.setText(Nazione);
tRegione.setText(Regione);
tCitta.setText(Citta);
tCap.setText(Cap);
tProvincia.setText(Provincia);
tIndirizzo.setText(Indirizzo);
tEmail.setText(Email);
tNumero.setText(Numero);
















share|improve this question






























    0















    I'm working on an Android app where I save the data in a MySQL database and then I have to display it in the TextView of the Android app.



    When the user clicks on the 'Information' button he must view all his information.



    The problem is that I don't understand how to do it, I tried to use the code of this tutorial "https://androidjson.com/android-php-insert-display-select-update-delete/", but the problem is that I don't I have a View list, I only have one button and I can't understand how to show the data of a single user.



    The android app it shows nothing, the data does not arrive.



    I also tried to passed the user's id in the previous activity, but then I don't know how to show that user's data in the next activity.



    My table in MySQL is called Restaurants and has 11 fields.



    • idR

    • LocalName

    • MediumPrize

    • Country

    • Region

    • Province

    • Cap

    • Address

    • Email

    • Telephone Number

    My php code is :



    <?php

    if($_SERVER['REQUEST_METHOD']=='POST')

    include 'config.php';

    $idR= r285602265407430;

    // Create connection
    $conn = new mysqli($HostName, $HostUser, $HostPass, $DatabaseName);

    if ($conn->connect_error)

    die("Connection failed: " . $conn->connect_error);


    $sql = "SELECT * FROM Ristoranti WHERE idR = '$idR'" ;

    $result = $conn->query($sql);

    if ($result->num_rows >0)


    while($row[] = $result->fetch_assoc())

    $tem = $row;

    $json = json_encode($tem);

    echo 'culo';



    else
    echo "No Results Found.";

    echo $json;

    $conn->close();

    ?>


    My Java code is :



    import android.app.ProgressDialog;
    import android.content.Context;
    import android.content.Intent;
    import android.os.AsyncTask;
    import android.support.v7.app.AppCompatActivity;
    import android.os.Bundle;
    import android.view.View;
    import android.widget.Button;
    import android.widget.EditText;
    import android.widget.TextView;

    import org.json.JSONArray;
    import org.json.JSONException;
    import org.json.JSONObject;

    import java.util.HashMap;

    public class Modifica_info_base extends AppCompatActivity

    HttpParse_info httpParse = new HttpParse_info();
    ProgressDialog pDialog;


    // Http Url For Filter Student Data from Id Sent from previous activity.
    String HttpURL = "http://provaord.altervista.org/OrdPlace/InformazioniRistorante/filter_info_base.php";

    String finalResult ;
    HashMap<String,String> hashMap = new HashMap<>();
    String ParseResult ;
    HashMap<String,String> ResultHash = new HashMap<>();
    String FinalJSonObject ;
    String text;
    TextView tNomeRistorante, tPrezzoMedio, tNazione, tRegione, tCitta, tProvincia, tCap, tIndirizzo, tEmail, tNumero;
    String Nomeristorante, Prezzomedio, Nazione, Regione, Citta, Provincia, Cap, Indirizzo, Email, Numero;
    Button UpdateButton;
    String TempItem;
    ProgressDialog progressDialog2;
    EditText idR;

    @Override
    protected void onCreate(Bundle savedInstanceState)
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_modifica_info_base);

    tNomeRistorante = (TextView)findViewById(R.id.textView_nome_ristorante);
    tPrezzoMedio = (TextView)findViewById(R.id.textView_prezzo_medio);
    tNazione = (TextView)findViewById(R.id.textView_nazione);
    tRegione = (TextView)findViewById(R.id.textView_regione);
    tCitta = (TextView)findViewById(R.id.textView_citta);
    tProvincia = (TextView)findViewById(R.id.textView_provincia);
    tCap = (TextView)findViewById(R.id.textView_cap);
    tIndirizzo = (TextView)findViewById(R.id.textView_indirizzo);
    tEmail = (TextView)findViewById(R.id.textView_email);
    tNumero = (TextView)findViewById(R.id.textView_numero_telefono);

    idR = (EditText)findViewById(R.id.editText5id);

    UpdateButton = (Button)findViewById(R.id.button_modifica_info_base);

    TempItem = getIntent().getStringExtra("ListViewValue");

    final String text= idR.getEditableText().toString();

    //Calling method to filter Student Record and open selected record.
    HttpWebCall(text);

    UpdateButton.setOnClickListener(new View.OnClickListener()
    @Override
    public void onClick(View v)
    Intent intent = new Intent(Modifica_info_base.this,Messagge_ristoratore.class);

    // Sending Student Id, Name, Number and Class to next UpdateActivity.
    intent.putExtra("idR", String.valueOf(idR));
    intent.putExtra("NomeLocale", Nomeristorante);
    intent.putExtra("PrezzoMedio", Prezzomedio);
    intent.putExtra("Nazione", Nazione);
    intent.putExtra("Regione", Regione);
    intent.putExtra("Citta", Citta);
    intent.putExtra("Provincia", Provincia);
    intent.putExtra("Cap", Cap);
    intent.putExtra("Indirizzo", Indirizzo);
    intent.putExtra("Email", Email);
    intent.putExtra("Telefono", Numero);


    startActivity(intent);

    // Finishing current activity after opening next activity.
    finish();

    );



    //Method to show current record Current Selected Record
    public void HttpWebCall(final String PreviousListViewClickedItem)

    class HttpWebCallFunction extends AsyncTask<String,Void,String>

    @Override
    protected void onPreExecute()
    super.onPreExecute();

    pDialog = ProgressDialog.show(Modifica_info_base.this,"Loading Data",null,true,true);


    @Override
    protected void onPostExecute(String httpResponseMsg)

    super.onPostExecute(httpResponseMsg);

    pDialog.dismiss();

    //Storing Complete JSon Object into String Variable.
    FinalJSonObject = httpResponseMsg ;

    //Parsing the Stored JSOn String to GetHttpResponse Method.
    new GetHttpResponse(Modifica_info_base.this).execute();



    @Override
    protected String doInBackground(String... params)

    ResultHash.put("idR",params[0]);

    ParseResult = httpParse.postRequest(ResultHash, HttpURL);

    return ParseResult;



    HttpWebCallFunction httpWebCallFunction = new HttpWebCallFunction();

    httpWebCallFunction.execute(PreviousListViewClickedItem);



    // Parsing Complete JSON Object.
    private class GetHttpResponse extends AsyncTask<Void, Void, Void>

    public Context context;

    public GetHttpResponse(Context context)

    this.context = context;


    @Override
    protected void onPreExecute()

    super.onPreExecute();


    @Override
    protected Void doInBackground(Void... arg0)

    try

    if(FinalJSonObject != null)

    JSONArray jsonArray = null;

    try
    jsonArray = new JSONArray(FinalJSonObject);

    JSONObject jsonObject;

    for(int i=0; i<jsonArray.length(); i++)

    jsonObject = jsonArray.getJSONObject(i);

    // Storing Student Name, Phone Number, Class into Variables.
    Nomeristorante = jsonObject.getString("NomeLocale").toString() ;
    Prezzomedio = jsonObject.getString("PrezzoMedio").toString() ;
    Nazione = jsonObject.getString("Nazione").toString() ;
    Regione = jsonObject.getString("Regione").toString() ;
    Citta = jsonObject.getString("Citta").toString() ;
    Provincia = jsonObject.getString("Provincia").toString() ;
    Cap = jsonObject.getString("Cap").toString() ;
    Indirizzo = jsonObject.getString("Indirizzo").toString() ;
    Email = jsonObject.getString("Email").toString() ;
    Numero = jsonObject.getString("Telefono").toString() ;



    catch (JSONException e)
    e.printStackTrace();



    catch (Exception e)

    e.printStackTrace();

    return null;


    @Override
    protected void onPostExecute(Void result)


    tNomeRistorante.setText(Nomeristorante);
    tPrezzoMedio.setText(Prezzomedio);
    tNazione.setText(Nazione);
    tRegione.setText(Regione);
    tCitta.setText(Citta);
    tCap.setText(Cap);
    tProvincia.setText(Provincia);
    tIndirizzo.setText(Indirizzo);
    tEmail.setText(Email);
    tNumero.setText(Numero);
















    share|improve this question


























      0












      0








      0








      I'm working on an Android app where I save the data in a MySQL database and then I have to display it in the TextView of the Android app.



      When the user clicks on the 'Information' button he must view all his information.



      The problem is that I don't understand how to do it, I tried to use the code of this tutorial "https://androidjson.com/android-php-insert-display-select-update-delete/", but the problem is that I don't I have a View list, I only have one button and I can't understand how to show the data of a single user.



      The android app it shows nothing, the data does not arrive.



      I also tried to passed the user's id in the previous activity, but then I don't know how to show that user's data in the next activity.



      My table in MySQL is called Restaurants and has 11 fields.



      • idR

      • LocalName

      • MediumPrize

      • Country

      • Region

      • Province

      • Cap

      • Address

      • Email

      • Telephone Number

      My php code is :



      <?php

      if($_SERVER['REQUEST_METHOD']=='POST')

      include 'config.php';

      $idR= r285602265407430;

      // Create connection
      $conn = new mysqli($HostName, $HostUser, $HostPass, $DatabaseName);

      if ($conn->connect_error)

      die("Connection failed: " . $conn->connect_error);


      $sql = "SELECT * FROM Ristoranti WHERE idR = '$idR'" ;

      $result = $conn->query($sql);

      if ($result->num_rows >0)


      while($row[] = $result->fetch_assoc())

      $tem = $row;

      $json = json_encode($tem);

      echo 'culo';



      else
      echo "No Results Found.";

      echo $json;

      $conn->close();

      ?>


      My Java code is :



      import android.app.ProgressDialog;
      import android.content.Context;
      import android.content.Intent;
      import android.os.AsyncTask;
      import android.support.v7.app.AppCompatActivity;
      import android.os.Bundle;
      import android.view.View;
      import android.widget.Button;
      import android.widget.EditText;
      import android.widget.TextView;

      import org.json.JSONArray;
      import org.json.JSONException;
      import org.json.JSONObject;

      import java.util.HashMap;

      public class Modifica_info_base extends AppCompatActivity

      HttpParse_info httpParse = new HttpParse_info();
      ProgressDialog pDialog;


      // Http Url For Filter Student Data from Id Sent from previous activity.
      String HttpURL = "http://provaord.altervista.org/OrdPlace/InformazioniRistorante/filter_info_base.php";

      String finalResult ;
      HashMap<String,String> hashMap = new HashMap<>();
      String ParseResult ;
      HashMap<String,String> ResultHash = new HashMap<>();
      String FinalJSonObject ;
      String text;
      TextView tNomeRistorante, tPrezzoMedio, tNazione, tRegione, tCitta, tProvincia, tCap, tIndirizzo, tEmail, tNumero;
      String Nomeristorante, Prezzomedio, Nazione, Regione, Citta, Provincia, Cap, Indirizzo, Email, Numero;
      Button UpdateButton;
      String TempItem;
      ProgressDialog progressDialog2;
      EditText idR;

      @Override
      protected void onCreate(Bundle savedInstanceState)
      super.onCreate(savedInstanceState);
      setContentView(R.layout.activity_modifica_info_base);

      tNomeRistorante = (TextView)findViewById(R.id.textView_nome_ristorante);
      tPrezzoMedio = (TextView)findViewById(R.id.textView_prezzo_medio);
      tNazione = (TextView)findViewById(R.id.textView_nazione);
      tRegione = (TextView)findViewById(R.id.textView_regione);
      tCitta = (TextView)findViewById(R.id.textView_citta);
      tProvincia = (TextView)findViewById(R.id.textView_provincia);
      tCap = (TextView)findViewById(R.id.textView_cap);
      tIndirizzo = (TextView)findViewById(R.id.textView_indirizzo);
      tEmail = (TextView)findViewById(R.id.textView_email);
      tNumero = (TextView)findViewById(R.id.textView_numero_telefono);

      idR = (EditText)findViewById(R.id.editText5id);

      UpdateButton = (Button)findViewById(R.id.button_modifica_info_base);

      TempItem = getIntent().getStringExtra("ListViewValue");

      final String text= idR.getEditableText().toString();

      //Calling method to filter Student Record and open selected record.
      HttpWebCall(text);

      UpdateButton.setOnClickListener(new View.OnClickListener()
      @Override
      public void onClick(View v)
      Intent intent = new Intent(Modifica_info_base.this,Messagge_ristoratore.class);

      // Sending Student Id, Name, Number and Class to next UpdateActivity.
      intent.putExtra("idR", String.valueOf(idR));
      intent.putExtra("NomeLocale", Nomeristorante);
      intent.putExtra("PrezzoMedio", Prezzomedio);
      intent.putExtra("Nazione", Nazione);
      intent.putExtra("Regione", Regione);
      intent.putExtra("Citta", Citta);
      intent.putExtra("Provincia", Provincia);
      intent.putExtra("Cap", Cap);
      intent.putExtra("Indirizzo", Indirizzo);
      intent.putExtra("Email", Email);
      intent.putExtra("Telefono", Numero);


      startActivity(intent);

      // Finishing current activity after opening next activity.
      finish();

      );



      //Method to show current record Current Selected Record
      public void HttpWebCall(final String PreviousListViewClickedItem)

      class HttpWebCallFunction extends AsyncTask<String,Void,String>

      @Override
      protected void onPreExecute()
      super.onPreExecute();

      pDialog = ProgressDialog.show(Modifica_info_base.this,"Loading Data",null,true,true);


      @Override
      protected void onPostExecute(String httpResponseMsg)

      super.onPostExecute(httpResponseMsg);

      pDialog.dismiss();

      //Storing Complete JSon Object into String Variable.
      FinalJSonObject = httpResponseMsg ;

      //Parsing the Stored JSOn String to GetHttpResponse Method.
      new GetHttpResponse(Modifica_info_base.this).execute();



      @Override
      protected String doInBackground(String... params)

      ResultHash.put("idR",params[0]);

      ParseResult = httpParse.postRequest(ResultHash, HttpURL);

      return ParseResult;



      HttpWebCallFunction httpWebCallFunction = new HttpWebCallFunction();

      httpWebCallFunction.execute(PreviousListViewClickedItem);



      // Parsing Complete JSON Object.
      private class GetHttpResponse extends AsyncTask<Void, Void, Void>

      public Context context;

      public GetHttpResponse(Context context)

      this.context = context;


      @Override
      protected void onPreExecute()

      super.onPreExecute();


      @Override
      protected Void doInBackground(Void... arg0)

      try

      if(FinalJSonObject != null)

      JSONArray jsonArray = null;

      try
      jsonArray = new JSONArray(FinalJSonObject);

      JSONObject jsonObject;

      for(int i=0; i<jsonArray.length(); i++)

      jsonObject = jsonArray.getJSONObject(i);

      // Storing Student Name, Phone Number, Class into Variables.
      Nomeristorante = jsonObject.getString("NomeLocale").toString() ;
      Prezzomedio = jsonObject.getString("PrezzoMedio").toString() ;
      Nazione = jsonObject.getString("Nazione").toString() ;
      Regione = jsonObject.getString("Regione").toString() ;
      Citta = jsonObject.getString("Citta").toString() ;
      Provincia = jsonObject.getString("Provincia").toString() ;
      Cap = jsonObject.getString("Cap").toString() ;
      Indirizzo = jsonObject.getString("Indirizzo").toString() ;
      Email = jsonObject.getString("Email").toString() ;
      Numero = jsonObject.getString("Telefono").toString() ;



      catch (JSONException e)
      e.printStackTrace();



      catch (Exception e)

      e.printStackTrace();

      return null;


      @Override
      protected void onPostExecute(Void result)


      tNomeRistorante.setText(Nomeristorante);
      tPrezzoMedio.setText(Prezzomedio);
      tNazione.setText(Nazione);
      tRegione.setText(Regione);
      tCitta.setText(Citta);
      tCap.setText(Cap);
      tProvincia.setText(Provincia);
      tIndirizzo.setText(Indirizzo);
      tEmail.setText(Email);
      tNumero.setText(Numero);
















      share|improve this question
















      I'm working on an Android app where I save the data in a MySQL database and then I have to display it in the TextView of the Android app.



      When the user clicks on the 'Information' button he must view all his information.



      The problem is that I don't understand how to do it, I tried to use the code of this tutorial "https://androidjson.com/android-php-insert-display-select-update-delete/", but the problem is that I don't I have a View list, I only have one button and I can't understand how to show the data of a single user.



      The android app it shows nothing, the data does not arrive.



      I also tried to passed the user's id in the previous activity, but then I don't know how to show that user's data in the next activity.



      My table in MySQL is called Restaurants and has 11 fields.



      • idR

      • LocalName

      • MediumPrize

      • Country

      • Region

      • Province

      • Cap

      • Address

      • Email

      • Telephone Number

      My php code is :



      <?php

      if($_SERVER['REQUEST_METHOD']=='POST')

      include 'config.php';

      $idR= r285602265407430;

      // Create connection
      $conn = new mysqli($HostName, $HostUser, $HostPass, $DatabaseName);

      if ($conn->connect_error)

      die("Connection failed: " . $conn->connect_error);


      $sql = "SELECT * FROM Ristoranti WHERE idR = '$idR'" ;

      $result = $conn->query($sql);

      if ($result->num_rows >0)


      while($row[] = $result->fetch_assoc())

      $tem = $row;

      $json = json_encode($tem);

      echo 'culo';



      else
      echo "No Results Found.";

      echo $json;

      $conn->close();

      ?>


      My Java code is :



      import android.app.ProgressDialog;
      import android.content.Context;
      import android.content.Intent;
      import android.os.AsyncTask;
      import android.support.v7.app.AppCompatActivity;
      import android.os.Bundle;
      import android.view.View;
      import android.widget.Button;
      import android.widget.EditText;
      import android.widget.TextView;

      import org.json.JSONArray;
      import org.json.JSONException;
      import org.json.JSONObject;

      import java.util.HashMap;

      public class Modifica_info_base extends AppCompatActivity

      HttpParse_info httpParse = new HttpParse_info();
      ProgressDialog pDialog;


      // Http Url For Filter Student Data from Id Sent from previous activity.
      String HttpURL = "http://provaord.altervista.org/OrdPlace/InformazioniRistorante/filter_info_base.php";

      String finalResult ;
      HashMap<String,String> hashMap = new HashMap<>();
      String ParseResult ;
      HashMap<String,String> ResultHash = new HashMap<>();
      String FinalJSonObject ;
      String text;
      TextView tNomeRistorante, tPrezzoMedio, tNazione, tRegione, tCitta, tProvincia, tCap, tIndirizzo, tEmail, tNumero;
      String Nomeristorante, Prezzomedio, Nazione, Regione, Citta, Provincia, Cap, Indirizzo, Email, Numero;
      Button UpdateButton;
      String TempItem;
      ProgressDialog progressDialog2;
      EditText idR;

      @Override
      protected void onCreate(Bundle savedInstanceState)
      super.onCreate(savedInstanceState);
      setContentView(R.layout.activity_modifica_info_base);

      tNomeRistorante = (TextView)findViewById(R.id.textView_nome_ristorante);
      tPrezzoMedio = (TextView)findViewById(R.id.textView_prezzo_medio);
      tNazione = (TextView)findViewById(R.id.textView_nazione);
      tRegione = (TextView)findViewById(R.id.textView_regione);
      tCitta = (TextView)findViewById(R.id.textView_citta);
      tProvincia = (TextView)findViewById(R.id.textView_provincia);
      tCap = (TextView)findViewById(R.id.textView_cap);
      tIndirizzo = (TextView)findViewById(R.id.textView_indirizzo);
      tEmail = (TextView)findViewById(R.id.textView_email);
      tNumero = (TextView)findViewById(R.id.textView_numero_telefono);

      idR = (EditText)findViewById(R.id.editText5id);

      UpdateButton = (Button)findViewById(R.id.button_modifica_info_base);

      TempItem = getIntent().getStringExtra("ListViewValue");

      final String text= idR.getEditableText().toString();

      //Calling method to filter Student Record and open selected record.
      HttpWebCall(text);

      UpdateButton.setOnClickListener(new View.OnClickListener()
      @Override
      public void onClick(View v)
      Intent intent = new Intent(Modifica_info_base.this,Messagge_ristoratore.class);

      // Sending Student Id, Name, Number and Class to next UpdateActivity.
      intent.putExtra("idR", String.valueOf(idR));
      intent.putExtra("NomeLocale", Nomeristorante);
      intent.putExtra("PrezzoMedio", Prezzomedio);
      intent.putExtra("Nazione", Nazione);
      intent.putExtra("Regione", Regione);
      intent.putExtra("Citta", Citta);
      intent.putExtra("Provincia", Provincia);
      intent.putExtra("Cap", Cap);
      intent.putExtra("Indirizzo", Indirizzo);
      intent.putExtra("Email", Email);
      intent.putExtra("Telefono", Numero);


      startActivity(intent);

      // Finishing current activity after opening next activity.
      finish();

      );



      //Method to show current record Current Selected Record
      public void HttpWebCall(final String PreviousListViewClickedItem)

      class HttpWebCallFunction extends AsyncTask<String,Void,String>

      @Override
      protected void onPreExecute()
      super.onPreExecute();

      pDialog = ProgressDialog.show(Modifica_info_base.this,"Loading Data",null,true,true);


      @Override
      protected void onPostExecute(String httpResponseMsg)

      super.onPostExecute(httpResponseMsg);

      pDialog.dismiss();

      //Storing Complete JSon Object into String Variable.
      FinalJSonObject = httpResponseMsg ;

      //Parsing the Stored JSOn String to GetHttpResponse Method.
      new GetHttpResponse(Modifica_info_base.this).execute();



      @Override
      protected String doInBackground(String... params)

      ResultHash.put("idR",params[0]);

      ParseResult = httpParse.postRequest(ResultHash, HttpURL);

      return ParseResult;



      HttpWebCallFunction httpWebCallFunction = new HttpWebCallFunction();

      httpWebCallFunction.execute(PreviousListViewClickedItem);



      // Parsing Complete JSON Object.
      private class GetHttpResponse extends AsyncTask<Void, Void, Void>

      public Context context;

      public GetHttpResponse(Context context)

      this.context = context;


      @Override
      protected void onPreExecute()

      super.onPreExecute();


      @Override
      protected Void doInBackground(Void... arg0)

      try

      if(FinalJSonObject != null)

      JSONArray jsonArray = null;

      try
      jsonArray = new JSONArray(FinalJSonObject);

      JSONObject jsonObject;

      for(int i=0; i<jsonArray.length(); i++)

      jsonObject = jsonArray.getJSONObject(i);

      // Storing Student Name, Phone Number, Class into Variables.
      Nomeristorante = jsonObject.getString("NomeLocale").toString() ;
      Prezzomedio = jsonObject.getString("PrezzoMedio").toString() ;
      Nazione = jsonObject.getString("Nazione").toString() ;
      Regione = jsonObject.getString("Regione").toString() ;
      Citta = jsonObject.getString("Citta").toString() ;
      Provincia = jsonObject.getString("Provincia").toString() ;
      Cap = jsonObject.getString("Cap").toString() ;
      Indirizzo = jsonObject.getString("Indirizzo").toString() ;
      Email = jsonObject.getString("Email").toString() ;
      Numero = jsonObject.getString("Telefono").toString() ;



      catch (JSONException e)
      e.printStackTrace();



      catch (Exception e)

      e.printStackTrace();

      return null;


      @Override
      protected void onPostExecute(Void result)


      tNomeRistorante.setText(Nomeristorante);
      tPrezzoMedio.setText(Prezzomedio);
      tNazione.setText(Nazione);
      tRegione.setText(Regione);
      tCitta.setText(Citta);
      tCap.setText(Cap);
      tProvincia.setText(Provincia);
      tIndirizzo.setText(Indirizzo);
      tEmail.setText(Email);
      tNumero.setText(Numero);













      php android mysql






      share|improve this question















      share|improve this question













      share|improve this question




      share|improve this question








      edited Mar 24 at 12:11









      halfer

      14.9k759121




      14.9k759121










      asked Mar 24 at 10:15







      user11133689





























          1 Answer
          1






          active

          oldest

          votes


















          0














          Use OKhttp3 library. its easy for handle web service calls. and see this tutorial about get data from json encoded text Json parser






          share|improve this answer























            Your Answer






            StackExchange.ifUsing("editor", function ()
            StackExchange.using("externalEditor", function ()
            StackExchange.using("snippets", function ()
            StackExchange.snippets.init();
            );
            );
            , "code-snippets");

            StackExchange.ready(function()
            var channelOptions =
            tags: "".split(" "),
            id: "1"
            ;
            initTagRenderer("".split(" "), "".split(" "), channelOptions);

            StackExchange.using("externalEditor", function()
            // Have to fire editor after snippets, if snippets enabled
            if (StackExchange.settings.snippets.snippetsEnabled)
            StackExchange.using("snippets", function()
            createEditor();
            );

            else
            createEditor();

            );

            function createEditor()
            StackExchange.prepareEditor(
            heartbeatType: 'answer',
            autoActivateHeartbeat: false,
            convertImagesToLinks: true,
            noModals: true,
            showLowRepImageUploadWarning: true,
            reputationToPostImages: 10,
            bindNavPrevention: true,
            postfix: "",
            imageUploader:
            brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
            contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
            allowUrls: true
            ,
            onDemand: true,
            discardSelector: ".discard-answer"
            ,immediatelyShowMarkdownHelp:true
            );



            );













            draft saved

            draft discarded


















            StackExchange.ready(
            function ()
            StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f55322720%2fget-and-show-data-from-mysql-of-a-single-user-in-the-android-app%23new-answer', 'question_page');

            );

            Post as a guest















            Required, but never shown
























            1 Answer
            1






            active

            oldest

            votes








            1 Answer
            1






            active

            oldest

            votes









            active

            oldest

            votes






            active

            oldest

            votes









            0














            Use OKhttp3 library. its easy for handle web service calls. and see this tutorial about get data from json encoded text Json parser






            share|improve this answer



























              0














              Use OKhttp3 library. its easy for handle web service calls. and see this tutorial about get data from json encoded text Json parser






              share|improve this answer

























                0












                0








                0







                Use OKhttp3 library. its easy for handle web service calls. and see this tutorial about get data from json encoded text Json parser






                share|improve this answer













                Use OKhttp3 library. its easy for handle web service calls. and see this tutorial about get data from json encoded text Json parser







                share|improve this answer












                share|improve this answer



                share|improve this answer










                answered Mar 24 at 10:34









                Ananth HanimanAnanth Haniman

                64




                64





























                    draft saved

                    draft discarded
















































                    Thanks for contributing an answer to Stack Overflow!


                    • Please be sure to answer the question. Provide details and share your research!

                    But avoid


                    • Asking for help, clarification, or responding to other answers.

                    • Making statements based on opinion; back them up with references or personal experience.

                    To learn more, see our tips on writing great answers.




                    draft saved


                    draft discarded














                    StackExchange.ready(
                    function ()
                    StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f55322720%2fget-and-show-data-from-mysql-of-a-single-user-in-the-android-app%23new-answer', 'question_page');

                    );

                    Post as a guest















                    Required, but never shown





















































                    Required, but never shown














                    Required, but never shown












                    Required, but never shown







                    Required, but never shown

































                    Required, but never shown














                    Required, but never shown












                    Required, but never shown







                    Required, but never shown







                    Popular posts from this blog

                    Kamusi Yaliyomo Aina za kamusi | Muundo wa kamusi | Faida za kamusi | Dhima ya picha katika kamusi | Marejeo | Tazama pia | Viungo vya nje | UrambazajiKuhusu kamusiGo-SwahiliWiki-KamusiKamusi ya Kiswahili na Kiingerezakuihariri na kuongeza habari

                    Swift 4 - func physicsWorld not invoked on collision? The Next CEO of Stack OverflowHow to call Objective-C code from Swift#ifdef replacement in the Swift language@selector() in Swift?#pragma mark in Swift?Swift for loop: for index, element in array?dispatch_after - GCD in Swift?Swift Beta performance: sorting arraysSplit a String into an array in Swift?The use of Swift 3 @objc inference in Swift 4 mode is deprecated?How to optimize UITableViewCell, because my UITableView lags

                    Access current req object everywhere in Node.js ExpressWhy are global variables considered bad practice? (node.js)Using req & res across functionsHow do I get the path to the current script with Node.js?What is Node.js' Connect, Express and “middleware”?Node.js w/ express error handling in callbackHow to access the GET parameters after “?” in Express?Modify Node.js req object parametersAccess “app” variable inside of ExpressJS/ConnectJS middleware?Node.js Express app - request objectAngular Http Module considered middleware?Session variables in ExpressJSAdd properties to the req object in expressjs with Typescript