Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to create a subpackage in android studio

Tags:

android

I am new to Android Studio.

Right now, my android Studio project only has a single package, the application package. How do I create a subpackage ?

Currently, the package for the MainActivity.java is: package com.davidgassner.plainolnotes.; I want the directory for the subpackage to be: packagecom.davidgassner.plainolnotes.data;

When I created the subpackage using your's and Android Studio's instruction I got the following: package com.davidgassner.plainolnotes.com.davidgassner.plainolnotes.data; I am getting an indication from Android Studio that the above path is not correct.

like image 966
Phillip Litt Avatar asked Jul 18 '15 21:07

Phillip Litt


People also ask

What is the right way to declare a package in Android?

Right click to src folder in your project->New->package. write the name of the package there->Finish. you will see the package what you named under src folder of your project. Add class files into that package.


1 Answers

Right click in your main package -> New -> Package -> Give a name to your package and there you go.

If your main package is com.davidgassner.plainolnotes and you want to create com.davidgassner.plainolnotes.data , follow the steps above and when asked to input the package name, supply only "data". It will be created like this:

+ com.davidgassner.plainolnotes
                             + data

In the top left corner you can switch your perspective from Android to Project to see all your project structure:

enter image description here

like image 107
vinitius Avatar answered Sep 24 '22 01:09

vinitius