android - Why value not same even call same variable -


this question has answer here:

    //global       getdatabasechart();     adddata();   public void adddata() {     int a;     = profile.gettotalbelum();     log.d("aa",""+a);     final float[] ydata = {a};     ......  }      public void getdatabasechart(){     //creating string request     log.d("masuktak","masuktak");     stringrequest stringrequest = new stringrequest(request.method.post, config.url_web + "a.php",             new response.listener<string>() {                 @override                 public void onresponse(string response) {                     //   hidepdialog();                     try {                          log.d("tgksini", response);                         jsonobject json = new jsonobject(response);                         int success = json.getint("success");                          if (success == 1) {                             user = json.getjsonarray("user");                              (int = 0; < user.length(); i++) {                                 jsonobject obj = user.getjsonobject(i);                                  profile = new profileuser();                                 profile.settotalbelum(obj.getint("belum"));                                log.d("belumb",string.valueof(profile.gettotalbelum()));                              }                             abc = profile.gettotalbelum();                             log.d("abccc", string.valueof(abc));                           } else {                             log.d("data2 ", "no user");                         } ............... 

this code .. change code .. direct integer value .. when see logcat .. check log.d abccc .. value abc = 2 ... check log.d aa value = 0 ...

how solve ? please me.

if try parse integer.

check before parsing. or handle exception properly. example:

try{    int = integer.parseint(profile.gettotalbelum()); }catch(numberformatexception ex){ // handle exception 

... }


Comments

Popular posts from this blog

scala - 'wrong top statement declaration' when using slick in IntelliJ -

c# - DevExpress.Wpf.Grid.InfiniteGridSizeException was unhandled -

PySide and Qt Properties: Connecting signals from Python to QML -