I’m using opencsv in my application but whenever I try to read my csv file, the application crashes.
Here’s the code I am using:
String next[] = {};
List<String[]> list = new ArrayList<String[]>();
try {
CSVReader reader = new CSVReader(new InputStreamReader(getAssets().open("sample.csv")));
} catch (IOException e) {
e.printStackTrace();
}
Whenever I try to comment out these lines, the app works just fine. What can be the possible problem with this?
Here’s the log whenever I click the button for opening the new activity that uses the code above:
03-21 11:59:28.147: E/AndroidRuntime(825): FATAL EXCEPTION: main
03-21 11:59:28.147: E/AndroidRuntime(825): java.lang.RuntimeException: Unable to start activity ComponentInfo{com.meralco.pms/com.meralco.pms.SinActivity}: java.lang.NullPointerException
03-21 11:59:28.147: E/AndroidRuntime(825): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2663)
03-21 11:59:28.147: E/AndroidRuntime(825): at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2679)
03-21 11:59:28.147: E/AndroidRuntime(825): at android.app.ActivityThread.access$2300(ActivityThread.java:125)
03-21 11:59:28.147: E/AndroidRuntime(825): at android.app.ActivityThread$H.handleMessage(ActivityThread.java:2033)
03-21 11:59:28.147: E/AndroidRuntime(825): at android.os.Handler.dispatchMessage(Handler.java:99)
03-21 11:59:28.147: E/AndroidRuntime(825): at android.os.Looper.loop(Looper.java:123)
03-21 11:59:28.147: E/AndroidRuntime(825): at android.app.ActivityThread.main(ActivityThread.java:4627)
03-21 11:59:28.147: E/AndroidRuntime(825): at java.lang.reflect.Method.invokeNative(Native Method)
03-21 11:59:28.147: E/AndroidRuntime(825): at java.lang.reflect.Method.invoke(Method.java:521)
03-21 11:59:28.147: E/AndroidRuntime(825): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:868)
03-21 11:59:28.147: E/AndroidRuntime(825): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:626)
03-21 11:59:28.147: E/AndroidRuntime(825): at dalvik.system.NativeStart.main(Native Method)
03-21 11:59:28.147: E/AndroidRuntime(825): Caused by: java.lang.NullPointerException
03-21 11:59:28.147: E/AndroidRuntime(825): at com.meralco.pms.SinActivity.onCreate(SinActivity.java:36)
03-21 11:59:28.147: E/AndroidRuntime(825): at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1047)
03-21 11:59:28.147: E/AndroidRuntime(825): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2627)
03-21 11:59:28.147: E/AndroidRuntime(825): ... 11 more
Please Go through entire log.
See Line number 36 if you have done any mistake there.Post onCreate code so can have a look
Hope this helps.