Where to place an XML file containing data within an Android app
You can put it in the res/raw folder. Then you will access it using:
getResources().openRawResource(resourceName)
I'd say that depends. What do you save in your XML-File? There also is a res/xml
-folder, where XML-Files can be kept. But Android does nearly anything with XML-Files, so you might want to read my little Tutorial about where to put which recourses.
Also, there is a difference between the assets
and the res
-directory's:
res
- No subdirectorys are allowed under the specific resource-folders.
- The
R
-class indexes all resources and provides simple access. - There are some simple methods which
help reading files stored in the
res
-directory
assets
- Subdirectorys are allowed (as much as you like).
- No indexing by the
R
-class - Reading resources stored in
assets
is done using the AssetManager.