Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Where to place the 'assets' folder in Android Studio?

I am confused about the assets folder. It doesn't come auto-created in Android Studio, and almost all the forums in which this is discussed talk about Eclipse.

How can the Assets directory be configured in Android Studio?

like image 724
hvkale Avatar asked Aug 18 '13 18:08

hvkale


People also ask

Where do I put assets in Android Studio?

Since Android Studio uses the new Gradle-based build system, you should be putting assets/ inside of the source sets (e.g., src/main/assets/ ).

Where are Android assets stored?

I noticed that , when an android app is installed, It's apk file is copied to "data/app" directory. If I open it from there - just selecting view, I see assets folder which contains my files. That is correct. The APK is copied there during installation, but the asset files are left inside it.

What is the use of assets folder in Android?

Assets provide a way to include arbitrary files like text, xml, fonts, music, and video in your application. If you try to include these files as "resources", Android will process them into its resource system and you will not be able to get the raw data.

How do I add assets folder in Visual Studio?

You can open assets folder in Visual Studio Code by simply right-clicking it in Solution Explorer and select Open Assets in VS Code. On default, extension looks for [anyname]. assets folder in solution folder. If it finds, it will run VS Code in that directory.


2 Answers

Let Android Studio do it for you.

  1. In Android Studio (1.0 & above), right-click on the enter image description here folder and navigate to the Assets Folder.

enter image description here

  1. On the next screen just click Finish.

enter image description here

And voila! It will create the assets folder in the main target source set.

enter image description here

like image 23
Prince Avatar answered Oct 02 '22 00:10

Prince


Since Android Studio uses the new Gradle-based build system, you should be putting assets/ inside of the source sets (e.g., src/main/assets/).

In a typical Android Studio project, you will have an app/ module, with a main/ sourceset (app/src/main/ off of the project root), and so your primary assets would go in app/src/main/assets/. However:

  • If you need assets specific to a build type, such as debug versus release, you can create sourcesets for those roles (e.g,. app/src/release/assets/)

  • Your product flavors can also have sourcesets with assets (e.g., app/src/googleplay/assets/)

  • Your instrumentation tests can have an androidTest sourceset with custom assets (e.g., app/src/androidTest/assets/), though be sure to ask the InstrumentationRegistry for getContext(), not getTargetContext(), to access those assets

Also, a quick reminder: assets are read-only at runtime. Use internal storage, external storage, or the Storage Access Framework for read/write content.

like image 113
CommonsWare Avatar answered Oct 02 '22 00:10

CommonsWare