Use Assets

Description

Android offers one more directory for you to store resource files: /assets.

/assets is at the same level as /res.

The files in /assets do not generate IDs in R.java. You must specify the file path to read them.

The file path is a relative path starting at /assets.

Example

You use the AssetManager class to access these files.


String getStringFromAssetFile(Activity activity)
{//from  w w  w. j a va 2  s  .co  m
   AssetManager am = activity.getAssets();
   InputStream is = am.open("test.txt");
   String s = convertStreamToString(is);
   is.close();
   return s;
}




















Home »
  Android »
    Android Basics »




Hello Android
Resources
Activity
Calendar
Camera
Contact
Content Provider
Database
Hardware
Intent
Location
Media
Network
Notification
Preference
Sensor
Service
SMS