Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

195
Visualizações
get value of string outside void async method?

How do I get the value of String r outside the getInformation method? Specifically, I want to set String stringpwd equal to String r. (getInformation is a void method)

EDIT: I forgot to mention, I only want to set the value stringpwd after success has been completed.

                String user = emailaddress.getText().toString().trim();
                String pwd = password.getText().toString().trim();
                db.getInformation("password", user, new DatabaseHelper.MyCallback() {
                    @Override
                    public void success(String r) {
                        // Use result

                    }

                    @Override
                    public void failure(Throwable t) {
                        // Display error

                    }

                });

            

               String stringpwd = r;
over 4 years ago · Santiago Trujillo
1 Respostas
Responde à pergunta

0

You can define a global variable (example used below: userCpy), and initialise or store the value of string r in that variable making it availabe, elsewhere.

                String userCpy = null;         
                int flag = 0;    
                String user = emailaddress.getText().toString().trim();
                String pwd = password.getText().toString().trim();
                db.getInformation("password", user, new DatabaseHelper.MyCallback() {
                    @Override
                    public void success(String r) {
                        // Use result
                       userCpy = r;
                       flag = 1;
                    }

                    @Override
                    public void failure(Throwable t) {
                        // Display error

                    }

                });

               if(flag==1)
                   String stringpwd = userCpy;
over 4 years ago · Santiago Trujillo Relatório
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda