Home  >  Forum  >  Android
Post New Query

Android difference between res and assets


joined on
March 27,2014
Asked on August 24,2015
What is difference between res and assets directory in android project structure?


joined on
October 10,2013
Replied on August 26,2015

1. res and assets directory both can keep assets like images. In res/drawable, we can keep the images.

2. In assets, we can create our own folder, like image, video, textFile etc and can keep more than one assets accordingly.

3. If we have an image in res/drawable as image3.png, we use id as follows

imageView.setImageResource(R.drawable.image3)

4. To access image or any other file from assets folder, we need not any asset id, we can do it by AssetManager as follows

InputStream is = assetManager.open("img/image1.png");
Bitmap  bitmap = BitmapFactory.decodeStream(is);
imageView.setImageBitmap(bitmap);

Write Answer









Copyright ©2017 concretepage.com, all rights reserved |Privacy Policy | Contact Us