Reputation: 139
I want to separate my Java source code into different folders (e.g. folders for activities, fragments, etc like in https://blog.smartlogic.io/2013-07-09-organizing-your-android-development-code-structure/)
How do I create the new folders in Android Studio. The thing I thought might work is 'Right Click On The Package -> New -> Folder -> Java Folder' but this did not appear to do anything.
Upvotes: 8
Views: 11462
Reputation: 89
If you want make folder inside you package Right click in app -> new -> Sample Data Directory. You will find folder under app. move folder to any where you want. If you want to rename folder just click Shift + F6 in keyboard. After that if you make any class inside this folder just right click on the folder and choose new -> Java Class
Upvotes: -1
Reputation: 739
If you want to make a folder to put your Java files in it then go to -> new-> package and then move your files there but don't forget to change the package name in each file you move to the new package file.
Upvotes: 15
Reputation: 3235
We tried to organize Kotlin source code into different folders by using the following steps. Right-click package name under Java select New then Package. Then give the Package a name and Make the first letter a capital. Now put the MainActivity or any Activity you have in that folder. Now go take a look at your manifest file <activity android:name=".Controller.MainActivity">
.
It seems that when you create a Package (folder) the naming convention is no upper case letters are permitted. In our case, when we tried to add a new XML file Android Studio refused to Build the app until we fixed the problem.
We found no resources addressing this naming convention.
Upvotes: 2
Reputation: 338171
See the Java Tutorial on Packages.
A package in Java not only groups your classes together, it creates a namespace.
By convention, use a domain name in reverse direction to name your package.
package com.example.awesomeapp.login ;
Upvotes: 3