Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

193
Views
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 answers
Answer question

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 Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!