java - returns null while returning from nested loop -


i returning array string[] data, returns null. tried store array in data[] not worked, have values in strings(name,phone,temp,password) cant return..

public string[] searchuserdata(string email) {  string[] data= null; string temp,name,phone,password;      if (cr.movetofirst()) {          {             temp = cr.getstring(2);              if (temp.equals(email)) {                  //data[0]= cr.getstring(1);                 //data[1]= cr.getstring(2);                 //data[2]= cr.getstring31);                 //data[3]= cr.getstring41);                  name = cr.getstring(1);                 phone = cr.getstring(3);                 password = cr.getstring(4);                  log.i("values", name+" "+phone+" "+email+" "+password);               }          } while (cr.movetonext());         cr.close();     }     db.close();      return data;  } 

writing string[] data = new string[4]; start off.

this gives 4 elements in data array, set null.

these can accessed using data[0] through data[3]: array indexing in java 0-based.


Comments

Popular posts from this blog

Magento/PHP - Get phones on all members in a customer group -

php - .htaccess mod_rewrite for dynamic url which has domain names -

Website Login Issue developed in magento -