# Renaming an Activity There are two steps to renaming an Activity - Rename the Java file - Rename the XML layout file Because these filenames might be referenced in various other places of code throughout your entire app codebase, it is important to update all references. Android Studio has a method to automatically detect and update all references to the old filename. This feature is called **Refactor**. Follow the below steps to successfully complete a Refactor. ## Step 1/2: Rename the Java file - Right-click on the Java file, go to **Refactor** ⤇ **Rename** - Type the new name and click Enter - If your project is large and a **"Do Refactor"** button appears towards the bottom of your Android Studio screen, click that button to perform the rename - Click the gradle elephant icon on the top-right to Sync Project with Gradle Files ![](https://i.imgur.com/9EolZxc.gif =2000x) ## Step 2/2: Rename the XML layout file - Right-click on the corresponding XML file, go to **Refactor** ⤇ **Rename** - Type the new name and click Enter - If your project is large and a **"Do Refactor"** button appears towards the bottom of your Android Studio screen, click that button to perform the rename - Click the gradle elephant icon on the top-right to Sync Project with Gradle Files - Notice that all references to the old file have been automatically updated in all code files throughout your app ![](https://i.imgur.com/wC5zDmP.gif =2000x)