android - Get fields[].getName() as accessible String? -


i'm working on small function loads files 'raw' folder , then, based on prefix, determines wether or not should saved in vector. in preparation 'level-loading' mechanic want use game i'm making. function have works:

public void loadraws(){     field[] fields=r.raw.class.getfields();     for(int count=0; count < fields.length; count++){         stringstorage.add(fields[count].getname());     }      for(int = 0; < stringstorage.size(); i++){         log.i("asset", stringstorage.get(i));     } } 

the log.i(); function neatly prints filename logcat. however, when try like:

for(int = 0; < stringstorage.size()-1; i++){     message(stringstorage.get(i)); } 

to push message-box containing string, nullpointerexception. here's log:

11-19 14:08:51.881: e/androidruntime(4161): fatal exception: main 11-19 14:08:51.881: e/androidruntime(4161): process: com.example.whoops, pid: 4161 11-19 14:08:51.881: e/androidruntime(4161): java.lang.runtimeexception: unable start activity componentinfo{com.example.whoops/com.example.whoops.game}: java.lang.nullpointerexception 11-19 14:08:51.881: e/androidruntime(4161):     @ android.app.activitythread.performlaunchactivity(activitythread.java:2439) 11-19 14:08:51.881: e/androidruntime(4161):     @ android.app.activitythread.handlelaunchactivity(activitythread.java:2495) 11-19 14:08:51.881: e/androidruntime(4161):     @ android.app.activitythread.access$800(activitythread.java:153) 11-19 14:08:51.881: e/androidruntime(4161):     @ android.app.activitythread$h.handlemessage(activitythread.java:1349) 11-19 14:08:51.881: e/androidruntime(4161):     @ android.os.handler.dispatchmessage(handler.java:102) 11-19 14:08:51.881: e/androidruntime(4161):     @ android.os.looper.loop(looper.java:157) 11-19 14:08:51.881: e/androidruntime(4161):     @ android.app.activitythread.main(activitythread.java:5633) 11-19 14:08:51.881: e/androidruntime(4161):     @ java.lang.reflect.method.invokenative(native method) 11-19 14:08:51.881: e/androidruntime(4161):     @  java.lang.reflect.method.invoke(method.java:515) 11-19 14:08:51.881: e/androidruntime(4161):     @ com.android.internal.os.zygoteinit$methodandargscaller.run(zygoteinit.java:896) 11-19 14:08:51.881: e/androidruntime(4161):     @ com.android.internal.os.zygoteinit.main(zygoteinit.java:712) 11-19 14:08:51.881: e/androidruntime(4161):     @ dalvik.system.nativestart.main(native method) 11-19 14:08:51.881: e/androidruntime(4161): caused by: java.lang.nullpointerexception 11-19 14:08:51.881: e/androidruntime(4161):     @ android.content.contextwrapper.getapplicationinfo(contextwrapper.java:159) 11-19 14:08:51.881: e/androidruntime(4161):     @ android.view.contextthemewrapper.gettheme(contextthemewrapper.java:104) 11-19 14:08:51.881: e/androidruntime(4161):     @ android.app.alertdialog.resolvedialogtheme(alertdialog.java:143) 11-19 14:08:51.881: e/androidruntime(4161):     @ android.app.alertdialog$builder.<init>(alertdialog.java:360) 11-19 14:08:51.881: e/androidruntime(4161):     @ com.example.whoops.utillib.message(utillib.java:186) 11-19 14:08:51.881: e/androidruntime(4161):     @ com.example.whoops.levelstorage.loadraws(levelstorage.java:35) 11-19 14:08:51.881: e/androidruntime(4161):     @ com.example.whoops.game.oncreate(game.java:55) 11-19 14:08:51.881: e/androidruntime(4161):     @ android.app.activity.performcreate(activity.java:5312) 11-19 14:08:51.881: e/androidruntime(4161):     @ android.app.instrumentation.callactivityoncreate(instrumentation.java:1111) 11-19 14:08:51.881: e/androidruntime(4161):     @ android.app.activitythread.performlaunchactivity(activitythread.java:2395) 11-19 14:08:51.881: e/androidruntime(4161):     ... 11 more 

i have no idea why this, crucial names before defining ids of these files. have idea why error? , how solve it?

-zubaja

try

for(int = 0; < stringstorage.size()-1; i++){ try{      message(stringstorage.get(i));    }catch(exception e){     log.i("error @ index :",""+i);    } }  

you can catch null pointer , detect comes.


Comments

Popular posts from this blog

java - Oracle EBS .ClassNotFoundException: oracle.apps.fnd.formsClient.FormsLauncher.class ERROR -

c# - how to use buttonedit in devexpress gridcontrol -

nvd3.js - angularjs-nvd3-directives setting color in legend as well as in chart elements -