Get string from one class to another class in Android? -
i need string variable 1 class of project class,
in first class, made string type variable , global, this: name of class firstclass
public string firstclassvar;
and assigning value in method
public string requestforserverdata(string strurl) throws ioexception, unknownhostexception, illegalargumentexception, exception { //additional code firstclassvar = myobject.getstring("values"); //additional code }
now in second class, doing this:
public firstclass getvar; public void method{ string secondclassvar; secondclassvar=getvar.firstclassvar; }
by doing crashes. have done thing in firstclass is
public string getstringpublically() { return firstclassvar; }
and accessing class doing this
secondclassvar =getvar.getstringpublically();
and doing crashes app.
now bit new android, , don't know basic way access string class.
you can use sharedpreferences set/get values in class want. here topic it
Comments
Post a Comment