Friday, 21 August 2015

Project Sturcture In Android and Studio

In Android Bundle:
Once After you create a new project in eclipse, you will see the following top-level folders in your package explorer.


/src:android-project-structure-2
This folder will contain the Java source files that you will be creating. In the screenshot you can see the ‘activity’ files that were created for the sample project. The files inside this  folder will be organized according to the package structure. This is similar to the /src folder which is present in any normal Java project.

/gen:android-project-structure-3

This is also a source folder, but will be contain Java source files that will be automatically generated by the android platform. Notable among the generated Java files is the R class, which you see in the screenshot. The framework will generate R class file 

/Android {version Number}

This is the folder, which will contain the libraries (jars) that are need for the project. In the screenshot, you can see that it contains the framework jar file. This is similar to the /lib folder which is present in any normal Java project.

/resandroid-project-structure-4

This directory contains all the external resources (images, data files etc) that are used by the android application. These external resources (content) will be referenced in the android application.
This contains the following sub-folders
  • /res/drawable
  • /res/layout
  • /res/Values

/res/drawable:

This folder contains all images, pictures etc. If you want to include an image or an icon in your android application, then you will be placing it in this folder.

/res/layout:

This folder contains the UI layouts that will be used in the project. These UI layouts are stored as XML files. 

/res/Values

This folder again contains XML files, which contain key values pairs that will be referenced in the application. These XML files declare Arrays, colors, dimensions, strings etc. The main idea of having these values in a separate XML file is that the values can be used based on the locale without actually changing the source code. For example the messages in the application can be in different languages based on the use locale.

/assets

This folder also contains external resources used in the application like the /res folder. But the main difference is that the resources are stored in raw format and can be read only programmatically.

AndroidManifest.xml

This is an XML file which contains meta information about the android application and is important file for every android application project. It contains information about various activities, views, services etc. It also contains the list of user permissions that are needed to run the android application.

Project Structure in Android Studio:

Here is the brief description of important files/folders in the Android project structure:

  Manifests:

 AndroidManifest.xml is one of the most important file in the Android project structure. It contains all the information about your application. When an application is launched, the first file the system seeks is the AndroidManifest file. It actually works as a road map of your application, for the system.

The Android Manifest file contains information about:
  • Components of your application such as Activities, services etc.
  • User permissions required
  • Minimum level of Android API required

Java:

 The Java folder contains the Java source code files of your application organized into packages. You can have more than one package in your Android application. Its always a good practice to break the source code of your application into different packages based on its core functionality.  All the source files of your Activities, Services etc. go into this folder. In the above screen, you can see the source file of the Activity that we created for our project.

Res:

Res folder is where we store all our external resources for our applications such as images, layout XML files, strings, animations, audio files etc.

Sub folders:

Drawable

This folder contains the bitmap file to be used in the program. There are three different folders to store drawables. They are drawable-ldpidrawable-mdpi, drawable-hdpi.The folders are to provide alternative image resources to specific screen configurations. Ldpi, mdpi & hdpi stands for low density, medium density & high density screens respectively. The resources for each screen resolutions are stored in respective folders and the android system will choose it according to the pixel density of the device.

Layout

XML files that defines the User Interface goes in this folder.

Values

XML files that define simple values such as strings, arrays, integers, dimensions, colors, styles etc. are placed in this folder.

Menu

XML files that define menus in your application goes in this folder

 Gradle Scripts:

 Gradle scripts are used to automate tasks. Now we don’t have to bother much about this, we will cover it later. Only understand that we use this Gradle Scripts to automate certain tasks. It uses a language called Groovy.

Please Send Your Comments To ambilpura.sunil@gmail.com

NEXT Turotial : Types Of Layouts In Android 1 

No comments:

Post a Comment