ANATOMY OF AN ANDROID APPLICATION

Now that you have created your first Hello World Android application, it is time to dissect the innards of the Android project and examine all the parts that make everything work.

First, note the various files that make up an Android project in the Package Explorer in Eclipse (see Figure 1-29).

The various folders and their files are as follows:

  • src — Contains the .java source files for your project. In this example, there is one file, MainActivity.java. The MainActivity.java file is the source file for your activity. You will write the code for your application in this file.
  • Android 3.0 library — This item contains one file, android.jar, which contains all the class libraries needed for an Android application.
  • gen — Contains the R.java file, a compiler-generated file that references all the resources found in your project. You should not modify this file.
  • assets — This folder contains all the assets used by your application, such as HTML, text files, databases, etc.
  • res — This folder contains all the resources used in your application. It also contains a few other subfolders: drawable-<resolution>, layout, and values.
  • AndroidManifest.xml — This is the manifest file for your Android application. Here you specify the permissions needed by your application, as well as other features (such as intent-filters, receivers, etc.).

The

Get Beginning Android now with O’Reilly online learning.

O’Reilly members experience live online training, plus books, videos, and digital content from 200+ publishers.