Google+

Android4Beginners.com

Apps development for Android step by step

Lesson 0.8: Additional information about project structure in Android Studio: java and resources folders

Let’s look again at the project tree (if you can’t see it, just click Project tab on the left of the screen).  Previously we were navigating directly to activity_main.xml file, but now we try to look also on other folders and files. Don’t worry only on a few of them, most we would never have to touch.

At the top level of the project tree is a folder related to your project name (in our case MyFristAndroidAppProject) and it has subfolder with the app name (like MyFirstAndroidApp). Both are bold so it easy to find them.

On the next level we have three folders: build, libs (libraries) and src (source). We would modify only content of the last one.  There is a main folder inside divided into java and res (resources) folders. And both of them are our real focus.

In java folder are located Java files – let’s say it’s our program. Java is a computer language that we would use to write application code. There should be only one file inside at the moment:  MainActivity. You could open it… if you’re not afraid. Just joking – even if those commands in MainActivity file look weird you would understand them pretty soon. Java would become your mother tongue! Close MainActivity.java file now, we will come back here later.

To make it very simple: src folder keeps source code of Android App, java folder keeps programming code of an app and  res folder keeps resources (data) used by programming code… (Android Studio)

To make it very simple: src folder keeps source code of Android App, java folder keeps programming code of an app and res folder keeps resources (data) used by programming code… (Android Studio)

Res folder keeps resources – data for our Java program. It already has many subfolders and we will add even more later on. Drawable keeps graphics and images for our layout. There is a group of drawables folders as you can have dedicated graphics for various resolutions (those hdpi, mdpi, xhdpi and xxhdpi are relations to various screen resolutions).

Layout folder we already know. There are XML files with… layout. By the way XML is abbreviation of eXtensive Markup Language. This language enables describing data in the way they are readable both for human and machine. Menu folder has some data for menu.

Moreover there is a group of values folders. They keep values for various platforms, for instance values-v14 has dedicated data for devices with Android API starting from 14, so Ice Cream Sandwich, Jelly Beans and some future ones. What are the values? For instance text (strings) for various language versions of your app, dimensions for different screen sizes (big on big screens has to be bigger than on small screens…), colors, interface styles and so on. Of course strings or colors could stay the same on different screen sizes and systems – we could keep only one copy of them in main values folder.

So just to summarize: java folder is for app code files and res – for data. Data could be different like images, sounds, text, animations, various data files. Data are divided into folders for specific data types. Sometimes there are a few folders with one data type for specific screen size, resolution and orientation or operating system version.

Previous:
Next: