When we browse any apk we found there is one folder named assets. Now I want to access that folder programatically. so how should I proceed for that? (Input for the program will be apk file/just app name).
Asked
Active
Viewed 5.1k times
3 Answers
19
This will list all the files in the assets folder:
AssetManager assetManager = getAssets();
String[] files = assetManager.list("");
This to open a certian file:
InputStream input = assetManager.open(assetName);

Nermeen
- 15,883
- 5
- 59
- 72
-
Thanks a lot for your help but it is returning me only the files of my own application and i want to access the assets folder of another application. – AndroidDev Sep 12 '12 at 12:18
-
check http://stackoverflow.com/questions/2454477/access-assests-from-another-application – Nermeen Sep 12 '12 at 12:25
-
6You are not authorized to access other apps assets. Why would you want to do this anyway ? – Teovald Sep 12 '12 at 12:26
-
if i am having apk file of any application then i think it should be retrievable – AndroidDev Sep 12 '12 at 12:34
-
this only display to me "drawable, images sounds, webkit" and not the files I put into the assets directory? – JacksOnF1re May 05 '15 at 12:32
5
If you want to access file from assets folder use the following code:
InputStream is = getAssets().open("contacts.csv");
DefaultHttpClient httpClient = new DefaultHttpClient();
HttpGet httpGet = new HttpGet(is);
HttpContext localContext = new BasicHttpContext();
HttpResponse response =httpClient.execute(httpGet, localContext);
BufferedReader reader = new BufferedReader(new
InputStreamReader(response.getEntity().getContent()));
2
For example: If you have the .ttf file in your assets folder: then you used like this:
Typeface font = Typeface.createFromAsset(getAssets(), "MARKER.TTF");
Here is link: http://developer.android.com/guide/topics/resources/accessing-resources.html#ResourcesFromCode

Deepzz
- 4,573
- 1
- 28
- 52