Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Android - Package Name convention

Tags:

android

naming

For the "Hello World" example in android.com, the package name is
"package com.example.helloandroid;"

Is there any guideline/standard to name this package? (references would be nice)

like image 210
Charles Yeung Avatar asked Jun 08 '11 03:06

Charles Yeung


People also ask

How do you name packages on Android?

Package names are all lowercase, with consecutive words simply concatenated together (no underscores).

What is the naming convention for packages?

Naming ConventionsPackage names are written in all lower case to avoid conflict with the names of classes or interfaces. Companies use their reversed Internet domain name to begin their package names—for example, com. example. mypackage for a package named mypackage created by a programmer at example.com .

Can I change package name Android?

Step 1: To rename package name in Android studio open your project in Android mode first as shown in the below image. Step 2: Now click on the setting gear icon and deselect Compact Middle Packages. Step 3: Now the packages folder is broken into parts as shown in the below image.


1 Answers

Android follows normal java package conventions plus here is an important snippet of text to read (this is important regarding the wide use of xml files while developing on android).

The reason for having it in reverse order is to do with the layout on the storage media. If you consider each period ('.') in the application name as a path separator, all applications from a publisher would sit together in the path hierarchy. So, for instance, packages from Adobe would be of the form:

com.adobe.reader (Adobe Reader)

com.adobe.photoshop (Adobe Photoshop)

com.adobe.ideas (Adobe Ideas)

[Note that this is just an illustration and these may not be the exact package names.]

These could internally be mapped (respectively) to:

com/adobe/reader

com/adobe/photoshop

com/adobe/ideas

The concept comes from Package Naming Conventions in Java, more about which can be read here:*

http://en.wikipedia.org/wiki/Java_package#Package_naming_conventions

Source: http://www.quora.com/Why-do-a-majority-of-Android-package-names-begin-with-com

like image 158
Jimmy Huch Avatar answered Oct 08 '22 15:10

Jimmy Huch