Wednesday, 29 April 2015

HOW TO READ FILE FROM ASSET FOLDER FOR GET CONTENT ?

Steps :

1. Place your text file in the /assets directory under the Android project.
2. Use AssetManager class to access it.

Code Snippets :

         AssetManager am = context.getAssets();
InputStream is       = am.open("test.txt");

OR

 1you can also put the file in the /res/raw directory,
 2.where the file will be indexed and is accessible by an id in the R file:

InputStream is = getResources().openRawResource(R.raw.test);

No comments:

Post a Comment