0

I'm trying to load words into an arrayList from a txt file in the assets folder in my android program, and looking at the api, it says that AssetManager.list(String path) will "Return a String array of all the assets at the given path."

Does that mean that if I have a text file, words.txt, and I put in "words.txt" as the parameter for AssetManager.list(String), that it will return a String array of all the words in the txt file?

If not, how would I go about reading a txt file into an array in my android program?

I couldn't find a definition for "asset"

I'm using eclipse.

EDIT:

I'm not just asking what an asset is, I'm also asking about a specific method in the api and how to load strings into an arrayList

Alex Gittemeier
  • 5,224
  • 30
  • 55
gallardoelise
  • 342
  • 3
  • 17

3 Answers3

6

Android offers one more directory where you can keep files which also will be included in package. This directory called /assets. The difference between /res and /assets is that Android doesn’t generate IDs for assets content. You need to specify relative path and name for files inside /assets.

M D
  • 47,665
  • 9
  • 93
  • 114
0

assets/

This is empty. You can use it to store raw asset files. Files that you save here are compiled into an .apk file as-is, and the original filename is preserved. You can navigate this directory in the same way as a typical file system using URIs and read files as a stream of bytes using the AssetManager. For example, this is a good location for textures and game data.

Source

Asset Usage Example

fida1989
  • 3,234
  • 1
  • 27
  • 30
0

assets is place where you can normal files which you want to read in application as some point whenever needed. You save your files/directory's. And read in your application from input streams but you cannot write.

As far res concerned, they resource files which you can refer directly in your code. like strings, array of strings,images (drawables),style(android specific like css in html) and there is raw folder which stores all files binary and generates id for it.

Sush
  • 3,864
  • 2
  • 17
  • 35