Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

194
Vistas
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 Respuestas
Responde la pregunta

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 Denunciar
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda