Moberg
Moberg

Reputation: 5503

How to create new res folder in Android Studio

I want to add localized strings for my android app. Therefore I need a values-xx folder in my Res folder.

The original values folder has a blue dot, so I tried creating a new Package, but a package can't contain a hyphen so this must be wrong. Instead I tried right-clicking res and choosing New -> Android resource directory, but this time nothing happens. No dialog or reaction of any sort as I can see.

How do I create a values-xx folder?

Edit: I can create the folder from file explorer and it all works good. It is just irritating to not be able to do it from inside Android Studio.

Edit2: This bug is fixed in newer versions of Android Studio.

Upvotes: 25

Views: 69358

Answers (8)

jjonesdesign
jjonesdesign

Reputation: 399

For those finding this answer when trying to add a new res folder to a library.

Right-click java/kotlin folder > New > Folder > Res Folder

Upvotes: 0

Saket
Saket

Reputation: 41

Its very simple. I too had trouble initially. Lets break it stepwise:- 1) Open your project 2) Right click the res folder 3) Choose New 4) Chose Directory 5) Name the directory.

Thats it!! It works for a fresh project everytime!

Upvotes: 0

Shubhdeep Singh
Shubhdeep Singh

Reputation: 407

If you have already created a new directory but just don't see it in the Project Tools window. Do this

Click on Project Tools window >> Android(Drop Down) >> Click Project. Now you'll see all your Directories in res. See the picture:

enter image description here

Upvotes: 1

Rafee Ullah
Rafee Ullah

Reputation: 21

Lets assume i Want to create a folder named "Daylight" under res.

Step 1: Right click on res.

Step 2: Then go to New.

Step 3: Then go to Folder.

Step 4: Then go to Res Folder Option and select.

A window will be open.

Step 5: At that window check the unchecked box "Change Folder Location"

and as assumed we have to create folder "Daylight"

Step 6: SO name the newly created folder as daylight, in this format. src/main/res/Daylight

Step 7: Then, Finally Click finish.

Upvotes: 1

Suragch
Suragch

Reputation: 511646

When you are in the Android view (rather than Project or Packages) in Android studio, you just need to right click the "values" directory and choose New > "Values resource file".

enter image description here

That gives you a chose of different resources you can add. For example, if you want to add a different language to your app you can choose the Language option and press the ">>" button. If you want Swahili then select that from the list, type "strings" for the file name, and press OK.

enter image description here

Android Studio will automatically create a values-sw directory with the new strings.xml file in it. And in your Android file view you conveniently see both strings files together.

enter image description here

And it is a similar process for adding other types of resources (see my other example). You no longer have to manually add the directories (but you can do that too by right clicking the res directory and choosing New > Android resource directory).

Upvotes: 29

madhavan
madhavan

Reputation: 50

The values-xx folder we created is not showing, but when we create a file its asking =>I have created values-21 folder and then tried with creating an xml and it asks for choosing a directory =>I have updated to Android 1.02

Check the values-21 Sample

Upvotes: 1

Moberg
Moberg

Reputation: 5503

This bug is fixed in newer versions of Android Studio.

Upvotes: 1

rafaello
rafaello

Reputation: 2435

I had the same problem, what I did was create a values-xx folder inside the main directory (main>>right click>>new>>directory) and then moved that folder to res/ directory.

It's not beautiful but it is a workaround to create a folder with Android studio.

Upvotes: 4

Related Questions