Android Basics-Project file structure (iii)

Source: Internet
Author: User

Android Basics-Project file Structure (iii)Code source folder and resource folder

"Note" This project file structure is limited to Android projects under Android Studio!!!

in an Android project, the Code source folder has 4, namely Java, JNI, Aidl, RS, Resource folder has 3, respectively is assets, RES, resources. (The folder name here is the name under Project view, if you have questions, refer to Android Basics-The project's file structure (a) Android view vs. Project View )

The folder path and description are shown in the following table:

Project View

Brief description

App/src/main/java

Java source folder, which holds all Java code source files in the project.

App/src/main/jni

The C/C + + source folder, which holds all of the code source files in the project.

App/src/main/aidl

Aidl source folder, which holds the Android Interface Definition Language code source file in the project.

App/src/main/rs

Renderscript source folder, which holds the Renderscript code source files in the project.

App/src/main/assets

Store any resource files that the programmer wants to use, where the files cannot be called by R.

App/src/main/res

Store all the resource files in the project, including pictures, layouts, strings, and so on.

App/src/main/resources

This folder appears to hold Java resource files.

Note: This analysis of Java, JNI, aidl, assets, res folder, RS and Resources folder I have limited knowledge, do not know, or do not make comments to avoid misleading everyone.

A. Java folder

Java folders are folders that are used to store Java source code in a project, and in a Java folder, subfolders are generally created based on the company domain name and project name. If the company domain name is com.cnblogs, the project name is HelloWorld, then we will create a new folder under the Java folder Com/cnblogs/helloworld (both use lowercase letters), Folders with the name Com.cnblogs.helloworld are displayed directly in as, and the project package name that you write when you create a new project should also be Com.cnblogs.helloworld, and you can also use Com.cnblogs.helloworld when creating a new folder, as it automatically Create the appropriate folder hierarchy.

The Java language is the mainstream language of Android application development, can be used to control the business logic and performance of Android applications, learning Android application development needs a certain Java Foundation, advanced Android development must need not low Java level, So also need to grasp the Java language learning.

Second, the Jni folder

The Jni folder is a folder that is used to store the source/C + + code in the project, and the source code should be placed in the Jni folder in Android app development If you need to use a C/s function. JNI (Java Native Interface) is a feature of the Java platform (not specific to the Android system), in fact, the main definition of a number of JNI functions, so that developers can call these functions to implement Java code to call C/s Code, C + + Code can also call Java code, so that you can play the characteristics of each language. In general, we are the first to compile the written and C + + code into the corresponding platform of the dynamic library, Windows is generally a DLL file, Linux is generally so file, and then use Java code to invoke the function in the dynamic library. Applications that use JNI later lose the cross-platform nature of Java, and the compiled dynamic libraries only support their respective platforms.

Third, Aidl folder

The Aidl folder is a folder for storing Aidl source code in the project, aidl--android Interface definition Language, which is the Android interface definition language. is the language used to provide support for Android across processes. There is no sharing of memory between processes in the Android system, so there is a need to provide some mechanism for data communication between different processes. to enable other applications to access the services provided by the application, the Android system is implemented using remote procedure calls (Procedure Call,rpc). Like many other RPC-based solutions, Android uses an interface definition language (Interface definition Language,idl) to expose the interfaces of the service.

Four,Res folder

In the Android project, the most important resource files are stored in the Res folder, the files under the Res folder will participate in the compilation of the project, you can call the Res folder through the R file all the resource files. Res folder also mainly includes drawable, Layout, menu, mipmap, values and other folders, call Drawable folder under the test file can be used r.drawable.test, other folders and so on.

The Drawable folder is used to store some drawable resource files, slices, XML, and so on.

The layout folder is used to store layouts files, and controls provide display results primarily through layout layouts files.

The menu folder is used to store menus and sub-menu items.

The Mipmap folder is used to store icon files, such as application icons, which can also be placed under the Drawable folder.

The values folder is primarily used to store specific value class files, mainly in the form of key-value pairs of data storage, including string, color, style, integer and other data.

Five,Assets Folder

The Assets folder is a native file, and the Android system does not compile the resource files under assets, so we cannot access them through the R file. Can I access them through the absolute path of the resource? Because APK installation will be placed in the/data/app/**.apk directory, in the form of APK, asset/res and is bound to the APK, and will not be extracted to the/data/data/package name directory, so we can not directly get to assets absolute path. the Android system provides us with a Assetmanager tool class thatAssetmanager provides access to the application's original resource files, Allows you to open and read the original resource file that is bound together with the application as a simple byte stream.

Android Basics-Project file structure (iii)

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.