java - Displaying CSV values in ANDROID APPLICATIONS ( After opening the APK ) -
i have been searching methods display values in csv files android applications not successful. ( totally beginner java , android )
each time took codes modified internet, system either not working( test.apk has stopped working ) or totally displaying nothing in apk.
an overview of eclipse java perspective in following picture.
http://i.stack.imgur.com/kqqym.png
1 of codes used in program ( inside test.java ):
package com.test; import java.io.ioexception; import java.io.inputstream; import java.io.inputstreamreader; import java.util.arraylist; import java.util.list; import android.app.activity; import android.content.context; import android.content.res.assetmanager; import android.os.bundle; import android.view.menu; import au.com.bytecode.opencsv.csvreader; public class test extends activity { private list<string[]> readcsv; @override protected void oncreate(bundle savedinstancestate) { super.oncreate(savedinstancestate); setcontentview(r.layout.activity_test); } @override public boolean oncreateoptionsmenu(menu menu) { // inflate menu; adds items action bar if present. getmenuinflater().inflate(r.menu.test, menu); return true; } public final list<string[]> readcsv(context context) { list<string[]> questionlist = new arraylist<string[]>(); assetmanager assetmanager = context.getassets(); try { inputstream csvstream = assetmanager.open("velox-i obdh.csv"); inputstreamreader csvstreamreader = new inputstreamreader(csvstream); csvreader csvreader = new csvreader(csvstreamreader); string[] line; // throw away header csvreader.readnext(); while ((line = csvreader.readnext()) != null) { questionlist.add(line); } } catch (ioexception e) { e.printstacktrace(); } return questionlist; }
the 2nd code used ends not working
package com.test; import java.io.ioexception; import java.io.inputstream; import java.io.inputstreamreader; import java.util.arraylist; import java.util.list; import android.app.activity; import android.content.context; import android.content.res.assetmanager; import android.os.bundle; import android.view.menu; import au.com.bytecode.opencsv.csvreader; public class test extends activity { public final list<string[]> readcsv(context context) { list<string[]> questionlist = new arraylist<string[]>(); assetmanager assetmanager = context.getassets(); try { inputstream csvstream = assetmanager.open("velox-i obdh.csv"); inputstreamreader csvstreamreader = new inputstreamreader(csvstream); csvreader csvreader = new csvreader(csvstreamreader); string[] line; // throw away header csvreader.readnext(); while ((line = csvreader.readnext()) != null) { questionlist.add(line); } } catch (ioexception e) { e.printstacktrace(); } return questionlist; }
for information, using eclipse develop android application , did included opencsv.jar in libs also. question :
how can displaying values of 8 csv files 8 different activities?
when had csv reader code, how put java class , connect xml or android such values in csv can displayed.
some of examples of values in csv files:
920004,"psat_xbp_channel_mask" 920006,"psat_xbp_scan_duration" 920007,"psat_xbp_extended_pan_id_hi"
(there should more 1000 lines in total of 8 csv files).
so should now?
it have access csv files can see raw data.
in event, reocmmend check out project. open source project library helps android beginners. has number of csv utilities soap class handling webservices have used in 1 of big applications. works quite well.
Comments
Post a Comment