Tuesday, 3 January 2012

Modify your Project :


Renaming Parts of an Application

Sometimes a portion of an Android project needs to be renamed. Maybe a file was copied manually into the project, such as from this book. Maybe the application name has changed during development, and it needs to be reflected in the file system tree. Automatic tools help with this and ensure cross-references are automatically updated. For example, in the Eclipse IDE, the different ways to rename portions of an application are



 Rename the Android project, as follows:



1. Right-click the project and Refactor > Move to a new directory in the

    File system.

2. Right-click the project and Refactor ­> Rename the project.



Rename an Android package, as follows:



1. Right-click the package and Refactor > Rename the package.

2. Edit the AndroidManifest.xml to ensure the new package name is reflected.



Rename an Android class (such as the major components Activity, Service, BroadcastReceiver, ContentProvider), as follows:

1. Right-click the .java file and Refactor > Rename the class.

2. Edit the AndroidManifest.xml to ensure the android: name has the new

component name.
Note that renaming other files, such as XML files, usually requires manually changing the corresponding references in the Java code.

No comments:

Post a Comment