java - How to get a specific column value from multile column from CSV file in ANDROID -


i'm trying values csv file getting error file not found. new android programming. have tried csvreader getting same error. tried these methods

try {     mng = getapplicationcontext().getassets();     test = mng.open("test.csv");     reader = new bufferedreader(newinputstreamreader(test));      for(l=0;((nextline = reader.readline()) != null);l++){           string[] cols = nextline.split(",");          b[l]=cols[0];          m[l]=integer.parseint(b[l]);                             }     arrays.sort(m); }  catch (ioexception e1) {     // todo auto-generated catch block     e1.printstacktrace(); } 

logcat error.:

02-08 17:55:22.314: i/dalvikvm(2856): not find method android.content.res.typedarray.getchangingconfigurations, referenced method android.support.v7.internal.widget.tinttypedarray.getchangingconfigurations 02-08 17:55:22.314: w/dalvikvm(2856): vfy: unable resolve virtual method 411: landroid/content/res/typedarray;.getchangingconfigurations ()i 02-08 17:55:22.314: d/dalvikvm(2856): vfy: replacing opcode 0x6e @ 0x0002 02-08 17:55:22.314: i/dalvikvm(2856): not find method android.content.res.typedarray.gettype, referenced method android.support.v7.internal.widget.tinttypedarray.gettype 02-08 17:55:22.314: w/dalvikvm(2856): vfy: unable resolve virtual method 433: landroid/content/res/typedarray;.gettype (i)i 02-08 17:55:22.314: d/dalvikvm(2856): vfy: replacing opcode 0x6e @ 0x0002 02-08 17:55:22.354: i/dalvikvm(2856): not find method android.content.res.resources.getdrawable, referenced method android.support.v7.internal.widget.resourceswrapper.getdrawable 02-08 17:55:22.354: w/dalvikvm(2856): vfy: unable resolve virtual method 374: landroid/content/res/resources;.getdrawable (ilandroid/content/res/resources$theme;)landroid/graphics/drawable/drawable; 02-08 17:55:22.354: d/dalvikvm(2856): vfy: replacing opcode 0x6e @ 0x0002 02-08 17:55:22.354: i/dalvikvm(2856): not find method android.content.res.resources.getdrawablefordensity, referenced method android.support.v7.internal.widget.resourceswrapper.getdrawablefordensity 02-08 17:55:22.354: w/dalvikvm(2856): vfy: unable resolve virtual method 376: landroid/content/res/resources;.getdrawablefordensity (iilandroid/content/res/resources$theme;)landroid/graphics/drawable/drawable; 02-08 17:55:22.354: d/dalvikvm(2856): vfy: replacing opcode 0x6e @ 0x0002 02-08 17:55:22.444: d/libegl(2856): loaded /vendor/lib/egl/libegl_adreno.so 02-08 17:55:22.454: d/libegl(2856): loaded /vendor/lib/egl/libglesv1_cm_adreno.so 02-08 17:55:22.484: d/libegl(2856): loaded /vendor/lib/egl/libglesv2_adreno.so 02-08 17:55:22.484: i/adreno-egl(2856): <qegldrvapi_eglinitialize:316>: egl 1.4 qualcomm build:  (cl4169980) 02-08 17:55:22.484: i/adreno-egl(2856): opengl es shader compiler version: 17.01.10.spl 02-08 17:55:22.484: i/adreno-egl(2856): build date: 11/04/13 mon 02-08 17:55:22.484: i/adreno-egl(2856): local branch:  02-08 17:55:22.484: i/adreno-egl(2856): remote branch:  02-08 17:55:22.484: i/adreno-egl(2856): local patches:  02-08 17:55:22.484: i/adreno-egl(2856): reconstruct branch:  02-08 17:55:22.764: d/openglrenderer(2856): enabling debug mode 0 02-08 17:55:24.526: d/absolutepath(2856): /storage/emulated/0 02-08 17:55:24.526: w/system.err(2856): java.io.filenotfoundexception: /storage/emulated/0/null.csv: open failed: enoent (no such file or directory) 02-08 17:55:24.586: w/system.err(2856):     @ libcore.io.iobridge.open(iobridge.java:420) 02-08 17:55:24.586: w/system.err(2856):     @ java.io.fileinputstream.<init>(fileinputstream.java:78) 02-08 17:55:24.586: w/system.err(2856):     @ java.io.filereader.<init>(filereader.java:42) 02-08 17:55:24.586: w/system.err(2856):     @ com.example.datapass.myfirst$1.onclick(myfirst.java:54) 02-08 17:55:24.586: w/system.err(2856):     @ android.view.view.performclick(view.java:4421) 02-08 17:55:24.586: w/system.err(2856):     @ android.view.view$performclick.run(view.java:17903) 02-08 17:55:24.586: w/system.err(2856):     @ android.os.handler.handlecallback(handler.java:730) 02-08 17:55:24.586: w/system.err(2856):     @ android.os.handler.dispatchmessage(handler.java:92) 02-08 17:55:24.586: w/system.err(2856):     @ android.os.looper.loop(looper.java:213) 02-08 17:55:24.586: w/system.err(2856):     @ android.app.activitythread.main(activitythread.java:5225) 02-08 17:55:24.586: w/system.err(2856):     @ java.lang.reflect.method.invokenative(native method) 02-08 17:55:24.586: w/system.err(2856):     @ java.lang.reflect.method.invoke(method.java:525) 02-08 17:55:24.586: w/system.err(2856):     @ com.android.internal.os.zygoteinit$methodandargscaller.run(zygoteinit.java:741) 02-08 17:55:24.586: w/system.err(2856):     @ com.android.internal.os.zygoteinit.main(zygoteinit.java:557) 02-08 17:55:24.586: w/system.err(2856):     @ dalvik.system.nativestart.main(native method) 02-08 17:55:24.596: w/system.err(2856): caused by: libcore.io.errnoexception: open failed: enoent (no such file or directory) 02-08 17:55:24.596: w/system.err(2856):     @ libcore.io.posix.open(native method) 02-08 17:55:24.596: w/system.err(2856):     @ libcore.io.blockguardos.open(blockguardos.java:110) 02-08 17:55:24.596: w/system.err(2856):     @ libcore.io.iobridge.open(iobridge.java:404) 02-08 17:55:24.596: w/system.err(2856):     ... 14 more 02-08 17:55:25.727: d/androidruntime(2856): shutting down vm 02-08 17:55:25.727: w/dalvikvm(2856): threadid=1: thread exiting uncaught exception (group=0x415648b0) 02-08 17:55:25.727: e/androidruntime(2856): fatal exception: main 02-08 17:55:25.727: e/androidruntime(2856): java.lang.nullpointerexception 02-08 17:55:25.727: e/androidruntime(2856):     @ com.example.datapass.mynew$1.onclick(mynew.java:68) 02-08 17:55:25.727: e/androidruntime(2856):     @ android.view.view.performclick(view.java:4421) 02-08 17:55:25.727: e/androidruntime(2856):     @ android.view.view$performclick.run(view.java:17903) 02-08 17:55:25.727: e/androidruntime(2856):     @ android.os.handler.handlecallback(handler.java:730) 02-08 17:55:25.727: e/androidruntime(2856):     @ android.os.handler.dispatchmessage(handler.java:92) 02-08 17:55:25.727: e/androidruntime(2856):     @ android.os.looper.loop(looper.java:213) 02-08 17:55:25.727: e/androidruntime(2856):     @ android.app.activitythread.main(activitythread.java:5225) 02-08 17:55:25.727: e/androidruntime(2856):     @ java.lang.reflect.method.invokenative(native method) 02-08 17:55:25.727: e/androidruntime(2856):     @ java.lang.reflect.method.invoke(method.java:525) 02-08 17:55:25.727: e/androidruntime(2856):     @ com.android.internal.os.zygoteinit$methodandargscaller.run(zygoteinit.java:741) 02-08 17:55:25.727: e/androidruntime(2856):     @ com.android.internal.os.zygoteinit.main(zygoteinit.java:557) 02-08 17:55:25.727: e/androidruntime(2856):     @ dalvik.system.nativestart.main(native method) 

error: " open failed: enoent (no such file or directory)"

to read data internal storage need app files folder , read content there:

string yourfilepath = context.getfilesdir() + "/" + "hello.txt"; file yourfile = new file( yourfilepath ); 

also can use approach:

   fileinputstream fis = context.openfileinput("hello.txt", context.mode_private);    inputstreamreader isr = new inputstreamreader(fis);    bufferedreader bufferedreader = new bufferedreader(isr);    stringbuilder sb = new stringbuilder();    string line;    while ((line = bufferedreader.readline()) != null) {        sb.append(line);    } 

Comments

Popular posts from this blog

javascript - jQuery: Add class depending on URL in the best way -

caching - How to check if a url path exists in the service worker cache -

Redirect to a HTTPS version using .htaccess -