Reputation: 189
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).
Upvotes: 15
Views: 51726
Reputation: 611
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()));
Upvotes: 5
Reputation:
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
Upvotes: 2
Reputation: 15973
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);
Upvotes: 19