Lesson Weekend

Our main package is starting to look a little messy. We have Java classes for our Restaurant model mixed up with Java classes for our user interface. Let’s create a few sub-packages to organize our project better.

To create a new sub-package, right click on the main package name and select New > Package:


creating-a-subpackage-in-android-studio

We will create the following three subpackages to better organize our project:

  • models, containing our Restaurant model and any future models.
  • ui , containing all of our activities.
  • services, containing our YelpService class.

Drag and drop each Java class into their corresponding packages and select Refactor from the dialog that appears:


refactor-dialog-box-with-subpackages

Once complete, our file tree in Android Studio should look like this:


refactored-file-tree-with-subpackages-android-studio


Example GitHub Repo for MyRestaurants