java - Excel file access from internal storage android app -
i want able copy excel file android app res\raw folder client phone's internal storage, , able retrieve data excel file , update excel file in internal storage needed. far have this:
http://developer.android.com/guide/topics/data/data-storage.html#filesinternal --- write files internal storage and
http://www.vogella.com/articles/javaexcel/article.html --- using jexcel retrieve data , edit excel file
i can't seem able link two. how go on implementing app?
thanks
for read , write use apache poi library
to sample example there android through read , write excel sheet
1) creating/reading excel file in android
2) android read write excel file using apache poi
for assets sdcard follow this link or use code.
package com.paresh.copyfileassetstoassets; import java.io.fileoutputstream; import java.io.ioexception; import java.io.inputstream; import java.io.outputstream; import android.app.activity; import android.content.res.assetmanager; import android.os.bundle; import android.os.environment; import android.util.log; public class copyfileassetstosdcardactivity extends activity { /** called when activity first created. */ @override public void oncreate(bundle savedinstancestate) { super.oncreate(savedinstancestate); setcontentview(r.layout.main); copyassets(); } private void copyassets() { assetmanager assetmanager = getassets(); string[] files = null; try { files = assetmanager.list("files"); } catch (ioexception e) { log.e("tag", e.getmessage()); } for(string filename : files) { system.out.println("file name => "+filename); inputstream in = null; outputstream out = null; try { in = assetmanager.open("files/"+filename); // if files resides inside "files" directory out = new fileoutputstream(environment.getexternalstoragedirectory().tostring() +"/" + filename); copyfile(in, out); in.close(); in = null; out.flush(); out.close(); out = null; } catch(exception e) { log.e("tag", e.getmessage()); } } } private void copyfile(inputstream in, outputstream out) throws ioexception { byte[] buffer = new byte[1024]; int read; while((read = in.read(buffer)) != -1){ out.write(buffer, 0, read); } } }
Comments
Post a Comment