Guys, I tried to solve this problem myself, but I couldn’t.
I have the docMain [0] line, which I take from the file on the phone, but even if it is null (checked), then the if check considers it not null anyway .
how to solve this? The code is correct.
if(docMain[0]==null){ //if language tag not have
println(“work hehehh”);
specialMenuLanguageSet(); mGFocus=-4;
}else{
println(“not work?”);
println(docMain[0]);
iconLanguage=loadImage(“iconLanguage”+docMain[0]+".png"); mGFocus=0;}
One problem could be that docMain is not properly initialized, so that the array itself is null. Therefore it is not possible to read the 0th entry, which would lead to a NullPointerException.
initialization is the setup of your array. You can check if an array is null (not a specific entry of the array, but the array itself) by creating a if-statement which goes as follows:
if(docMain==null){ //checks if docMain is iself null
println("array is null");
}else if(docMain[0]!=null){ //checks if array is null at position 0
println("entry at position 0 is "+docMain[0]);
}
if(docMain[0].equals("")){ //if language tag not have
println(“work hehehh”);
specialMenuLanguageSet(); mGFocus=-4;
}else{
println(“not work?”);
println(docMain[0]);
iconLanguage=loadImage(“iconLanguage”+docMain[0]+".png"); mGFocus=0;}
should do the work. Comparing strings with == does not work because Strings are objects, and Java compares object if they point at the same object, not the same content