Reading from a file using JAVA IO in android App -


i have file external jar needs. tried adding file assets , provided path straight away. din't work , threw error

java.io.filenotfoundexception: /assets/model/en2hi/tune/1/joshua.config: open failed: enoent (no such file or directory) 

the line external jar trying read file is:

fileinputstream fis = (filename.equals("-")) ? new fileinputstream(filedescriptor.in) : new fileinputstream(filename); 

please suggest on how can handled. there other way keeping application out of android app? or how allow android app read java io?

you can have file in /assets directory of project , access using assetmanager class:

assetmanager amgr= context.getassets(); inputstream ipstream = amgr.open("filename.txt"); 

or can have /res/raw directory , use using:

inputstream = getresources().openrawresource(r.raw.test); 

Comments

Popular posts from this blog

c# - DetailsView in ASP.Net - How to add another column on the side/add a control in each row? -

javascript - firefox memory leak -

Trying to import CSV file to a SQL Server database using asp.net and c# - can't find what I'm missing -