Android Project Directory

Android Studio displays directories of an Android project in Android view.  The structure is organized by modules and files as shown below. Here’s an example, showing some directories and files of Android Project Directory,

Android Project Directory

Java (java)

All the java files get stored under java directory.

Location: \app\src\main\java

Resource (res)

This directory consists of all the XML layouts, UI strings, drawable files, etc under sub-directories. The drawable sub-directory is where the images are saved.

Location: \app\src\main\res

Build (build)

It consists of the build output.

Libraries (libs)

It consists of private libraries.

Generated files (R.java)

Android Project Directory files also gets generated when compiled. Here, R.java file onsists of the Java files generated.

R.java consists of IDs for all the resources of the res directory. Do not modify this file, since it generates automatically when the project is compiled.

Location: \app\build\generated\

Assets (assets)

The assets folder consists of files that you want to compile into an .apk file as-is, for example, save font files here.

src (src)

The src directory consists of code and resource files.

Manifests (AndroidManifest.xml)

The AndroidManifest.xml provides important information about your app and is located in the root directory.

It provides a unique identifier to your app in the form of package name.

Sometimes you need to declare permissions so that users can interact with your app. The declaration is done in the AndroidManifest.xml file.

The minimum level of the Android API is also declared in this file. The Android API is what the application requires.

If you have added a new activity, then it should be listed under this file i.e. you need to describe the components of the app here i.e.

It describes other components as well, i.e. services, content providers, broadcast receivers, etc.

Strings Resources (strings.xml)

If you want to add text strings for your application, add it in the string resource file. You can also set text styling and formatting.

Location: res/values/strings.xml

Example

Here, you can see how we add string resources in strings.xml file and use it our activity file.

res/values/strings.xml

 res/layout/activity_main.xml

And here’s how we added it,

Under the activity file, we added the text “Studyopedia Demo App” first and then use keys Alt+Enter.

Now, select Create string value resource ‘title’,

Creating Android string value resource

Now, the following dialog box opens up, here add the Resource value as Studyopedia Demo App,

Add String Resource value

Style Resource

Let’s say you want to set style for your buttons, so that you do not need to add styling again and again in your activity file. For that, you need to add a separate style file. This would allow you to combine style resources in one file and reference it whenever you need it.

You can apply style to a View or even to a complete Activity.

Example

res/values/styles.xml

res/layout/quiz.xml


If you liked the tutorial, spread the word and share the link and our website Studyopedia with others.


For Videos, Join Our YouTube Channel: Join Now


Run Android app on hardware device
Understanding Gradle
Studyopedia Editorial Staff
contact@studyopedia.com

We work to create programming tutorials for all.

No Comments

Post A Comment

Discover more from Studyopedia

Subscribe now to keep reading and get access to the full archive.

Continue reading