Learning Android Development

Assets or Resource Raw folder of Android?

Guide to put your raw asset in the right location

Picture by geralt on Pixabay

Have you ever need to store your raw asset file (e.g. JSON, Text, mp3, pdf, etc) in your app? Where do you store them?

There are two possible locations: 1) assets, 2) res/raw folder.

Both of them seems to be the same, as they can read the file and generate InputStream as below

// From assets
assets
.open(assetPathFilename)
// From res/raw
resources
.openRawResource(resourceRawFilename)

But when to put where?

Below is some guidance that might be helpful to decide

1. Flexible filename: assets is better

assets folder

You can name your filename any way that you like here, like having a space (e.g. some file name), or having capital letters (e.g. someFileName).

res/raw folder

--

--