Day 2: Structure of Android Application Project

Introduction

 
We saw a number of files and folders in Package Explorer.
 
So in this article, we will talk about the various files and folders of an Android Project and what they mean actually.
 
Agenda
  1. src
  2. gen
  3. assets
  4. bin
  5. res
  6. layouts
  7. menus
  8. values
  9. AndroidManiefest.xml
Agenda
 
Content
  1. src: It contains the Java source file of your project. 
     
    Since every Android project needs a Java file because an Activity needs an XML layout, that is a front end of activity and Java file, that is a back end.
     
    By the front end, I mean the User Interface (UI) of your activity and in the back end, we define the behavior of UI views.
     
    UI views
     
    Analogous: Like in WPF or any Silverlight project, we need a XAML file in the front end (describes the UI) and C# file (.cs) file in the back end to define the behavior of the controls.

  2. gen: It contains an R.java file that manages all the resources.
     
    It is a compiler-generated file that references all the resources in your project. Most of the time you are asked to avoid modification in an R.java file. So, we do.
     
    Basically, this file is the only way to link an src/java file to an XML layout file.
     
    XML layout file
     
    Since we have multiple views (controls) in our XML file. How does the src/java file know about these resources?
     
    So, R.java maintains a list of resource IDs so that we can further access these resources from a Java file.
     
    java file
     
  3. assets: It contains all the assets like database, HTML file, text file.
     
  4. bin: This file contains the built file, in other words, the APK file is a binary application of the Android project.
     
    bin
     
  5. res: This folder contains the drawable file. Simply, all the image files are stored in this folder under the respective resolution.  

  6. layouts: Contains all the XML layouts files.
     
    Generally, an Android app has a number of activities and each is linked up with an XML layout file. Those layout files are stored in this folder.
     
    In our project, we have a single XML layout file, in other words, activity_main.xml is linked with MainActivity.java.
     
    Another is a fragment file that we will ignore for this discussion.
     
    layouts
     
  7. menu: This folder stores the XML file that defines the menu.
     
    Most of the interesting apps have an application menu and they are all defined inside the menu folder as XML files.
     
  8. values: This stores the strings.xml and styles.xml file.
     
    xml file
     
    Assume you have your app in English and the next day you want to upgrade your app to be in the French language. Then, you need to modify every text or just modify your string file.
     
    So it's better to modify the string.xml file than manage every text fields.
     
    modify the string
     
  9. AndroidManifest.xml: It is a meta-data file like any other meta file that stores information about activity and kind of permission required by the application.
     
    AndroidManifest
     

Conclusion

 
In the next article, we will try to do Navigation of Activity from one to another.


Similar Articles