Share my result

Asked

Viewed 69 times

1

Good afternoon, I created a football refereeing app... and looked on the internet to share the result I found this way(a member here of stackoverflow in English)

String message = "Text I want to share.";
    Intent share = new Intent(Intent.ACTION_SEND);
    share.setType("text/plain");
    share.putExtra(Intent.EXTRA_TEXT, message);

    startActivity(Intent.createChooser(share, "Title of the dialog the system will open"));

only that the recorded message would be String message = "Text I want to share.";

how would I appear the message in String which is in the database?

I tried that way and it didn’t work:

 String message = Esporte;
            Intent share = new Intent(Intent.ACTION_SEND);
            share.setType("text/plain");
            share.putExtra(Intent.EXTRA_TEXT, message);

            startActivity(Intent.createChooser(share, "Title of the dialog the system will open"));

My database (get and set):

package Base;

public class Esporte {

    private int id;
    private String nomeTimeUm;
    private String nomeTimeDois;
    private String jogadores;
    private int valorUm;
    private int valorDois;

    public Esporte(){}

    public Esporte(int id, String nomeTimeUm, String nomeTimeDois, String jogadores, int valorUm, int valorDois){
        this.id = id;
        this.nomeTimeUm = nomeTimeUm;
        this.nomeTimeDois = nomeTimeDois;
        this.jogadores = jogadores;
        this.valorUm = valorUm;
        this.valorDois = valorDois;
    }

    public int getId(){return id;}

    public void setId(int id){this.id = id;}

    public String getNomeTimeUm(){return nomeTimeUm;}

    public void setNomeTimeUm(String nomeTimeUm){this.nomeTimeUm = nomeTimeUm;}

    public String getNomeTimeDois(){return nomeTimeDois;}

    public void setNomeTimeDois(String nomeTimeDois){this.nomeTimeDois = nomeTimeDois;}

    public String getjogadores(){return jogadores;}

    public void setjogadores(String jogadores){this.jogadores = jogadores;}

    public int getValorUm(){return valorUm;}

    public void setValorUm(int valorUm){this.valorUm = valorUm;}

    public int getValorDois(){return valorDois;}

    public void setValorDois(int valorDois){this.valorDois = valorDois;}

    @Override
    public String toString(){
        return nomeTimeUm+ " X " +nomeTimeDois+
                " = " +valorUm+ " X " +valorDois + " -- " +jogadores;
    }

}

but I think I should take the last result I recorded in the bank and share... because if you take the nomeTimeUm, nomeTimeDois, valorUm and valorDois, He’ll get everyone in the bank... how would I do that

Note: Sport is mine get and set of the database

Thank you...

1 answer

3


Just give the toString() in the variable message, for example

Esporte objeto = ... recuperar as informações...
String message = objeto.ToString();
  • It worked here... thank you

Browser other questions tagged

You are not signed in. Login or sign up in order to post.