user5960138
user5960138

Reputation: 83

Is there anyway to put multiple activities in a folder in android studio?

I have multiple activities. For organization purposes I want to to put them in folders without affecting the project. How can this be done?

Upvotes: 0

Views: 1204

Answers (1)

guipivoto
guipivoto

Reputation: 18687

Just create a new folder. In fact, you can organize your project and separate the class as you want. This way, you keep your project organized and you can hide some methods and let them to be used only for classes in same package, for example.

I use do:

...\app\src\main\java\com\example\myapp\activities
...\app\src\main\java\com\example\myapp\service
...\app\src\main\java\com\example\myapp\dataprovider
...\app\src\main\java\com\example\myapp\adapters

So, your activities classes would start with:

package com.example.myapp.activities;

And your services would start with:

package com.example.myapp.service;

Also, you may need to adjust your imports:

import com.example.myapp.dataprovider.Class1;
import com.example.myapp.dataprovider.Class2;

However, this should be done automatically by Android Studio.

Just remember that doing that, you are creating a different packages. This way, you have to take a special attention with method accessbility (private, protected, public) However, since we usually use private and public modifiers, we should not have any problem.

Upvotes: 1

Related Questions