How to transfer a txt data file to my Android app -


I have to move the data file needed for my app. I read many threads on this subject and I understand how it Works. 1. I am using Android Studio 0.8.6. Many threads refer to the Folder property which apparently resides in src / main when I create a new project then the folder does not exist. I manually create one and I put it jpg and txt files. 2. I run the following code:

  AssetManager am = getAssets (); String [] file = new string [0]; Try {files = am.list ("files;} to hold (IOException e) {e.printStackTrace ();} (I int = 0; I & lt; files.length; i ++) {Toast.makeText ( GetApplicationContext (), "file:" + files [i] + "", toast.LENGTH_SHORT) .show ();}   

and I received a files.length = 0 1. I I can read files, write and write for long email, but I know where they live and what I want to do. I want to pass the data with the application. Sorry, but I am losing Thank you!

The code I used to read files from assets is listed below:

  public string ReadFromfile (string file name, reference reference) {StringBuilder returnString = new StringBuilder (); InputStream wings = null; InputStreamReader ISR = Null; BufferedReader input = null; try {wings = context.getResources ) GetAssets () .pen (.en file name, Context.MODE_WORLD_READABLE); ISR = new InputStreamReader (fin); Input = new BufferedReader (ISR); String line = ""; While ((line = input.r EadLine ()) = null) {returnString.append (line); }} Hold (exception e) {e.getMessage (); } Finally {try {if (isr! = Null) isr.close (); If (FN! = Null) fIn.close (); If (input! = Null) input.close (); } Hold (exception E2) {e2.getMessage (); }} Return Return String.toString (); }   

This code is not mine and can be found in the answers given below:



Comments

Popular posts from this blog

php - PDO bindParam() fatal error -

logging - How can I log both the Request.InputStream and Response.OutputStream traffic in my ASP.NET MVC3 Application for specific Actions? -

java - Why my included JSP file won't get processed correctly? -