'Listing of assets?
I want to add files to assets directory and how many there are and what their paths are. How I list of files in my assets directory?
Solution 1:[1]
How can I get a list of files in my assets directory?
Call list() on an AssetManager to get a list of assets packaged in your app. You can get an AssetManager by calling getAssets() on a Context.
Note that these are not files on the device. They are files on your development machine; they are merely assets in the app.
How can I form path strings or URLs to read each one individually?
That depends on what you mean by "read each one".
If you want to read the HTML in manually, call open() on the AssetManager, passing in the relative path to the asset.
IOW, for a file on your development machine in app/src/main/assets/hi/there.html, you would call open("hi/there.html")).
If you want to display the HTML in a WebView, use file:///android_asset/hi/there.html with loadUrl() on the WebView, for an asset located at the relative path hi/there.html.
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|---|
| Solution 1 | CommonsWare |
