I am new to android development, I am parsing a xml file through SAX parser and storing the parsed data into a string.Now i need to use that string in another class, so i need to know how to call that parser in the new class. thanks in advance
I always make a class that contains all of my globals and call it "Constants.java"
final public class Constants//final to prevent instantiation
{
public static final String SOME_STRING = "0.04";
public static final int SOME_NUMBER = 5;
public static final float METERS_PER_MILE = 1609.344f;
//private constructor to prevent instantiation/inheritance
private Constants()
{
}
}
to use one of these in your code, be sure to import the class and use:
Constants.SOME_NUMBER
You can use a static variable and can access it any where in the application
public static int myVar = 1;
access it by ClassName.myVar
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With