Android - Assets vs res folder

Hi all.

I’ve been learning Android recently and so far I’ve only touched the res folder to put my images/icon inside. However, when I use LibGDX I always put the images/music/sounds inside an assets folder inside the desktop project which then copies those files to the Android assets folder. I have a few questions based on this.

1: If I create different size images and place them inside the assets folder, how does the phone know which images to use? Do I need to change some code, etc?
2: When should I use the res/drawable folders over the assets folder and vice-versa
3: Does it even really matter about different size images? I know some phones/tablets support very large screen sizes and using LibGDX I use the viewport class to keep the aspect ratio, which means I only need 1 set of assets. I don’t mind creating multiple assets, just wondering how Android would handle this

In the res folder you can use images with different sizes, strings (.xml), special layouts for activities, dimens.xml for dimensions and all the content is automatically selected depending on the resolution of the device.

If you have an image.png in the drawable-ldpi and an image.png in the drawable-hdpi, your app will use the image from the current device without coding anything, same with the values-small/large.

In libGDX you have only one acitivity, so you are a bit more limited with layouts or other features, but you can still use (you can’t share the res folder and other specific platform features with desktop/ios/html5, I think). I can be wrong, if you are using libGDX you don’t need worry about the res folder for your assets from the game, especially if you are using some types of viewport, but for some Android features you need to use (e.g: icon launcher, androidmanifest.xml, implement some code for advertising banners, leaderboards, etc…).

For the res folder strategy (select different sizes automatically), libGDX has an interesting class called ResolutionFileResolver:

Thank you very much, Craftm. Just what I was looking for.

I’ve never heard of the ResolutionFileResolver class before! :o i’m going to take a look at it, could be really useful in the future.