DEV Community

Cover image for How to Organize Android Package / Folder Structure?
Vincent Tsen
Vincent Tsen

Posted on • Edited on • Originally published at vtsen.hashnode.dev

12 2

How to Organize Android Package / Folder Structure?

Of course, this is very personal. There is no right or wrong how you would like to organize your Android source code.

I prefer to organize my source code based on recommended Android app architecture, which is also known as MVVM architecture.

recommended_folder_structure_01.PNG

Image source: MindOrks

This is what my package/folder structure looks like in Java root folder.

Package / Folder Name Description
ui UI controller such as activity and fragment
viewmodel Data for the UI
repository Modules that handle data operation
local Room database - SQlite
remote Remote data source - Retrofit

This works for a small app, which is exactly what I’m doing now. However, I imagine if your app is huge and contributed by many developers, you may want to break it down into different modules/features instead.



Module1
└─── ui
└─── viewmodel
└─── repository
└─── local
└─── remote
    ...
Module2
└─── ui
└─── viewmodel
└─── repository
└─── local
└─── remote
    ...
...


Enter fullscreen mode Exit fullscreen mode

This allows your modules to be exported or shared as generic libraries easily in the future. Since my app is small, I'm good with what I'm doing now.

[Updated - July 02, 2022]: Given that I now have a bit of experience. This is my current package naming convention based on the latest app architecture guide.



root package
└─── data
     └─── local
     └─── mapper
     └─── remote
     └─── repository
└─── domain
     └─── model
     └─── repository
└─── ui
     └─── screens
     └─── theme
     └─── viewmodel
└─── utils


Enter fullscreen mode Exit fullscreen mode
  • mapper contains extension functions to convert data to and from different layers.

For app reference, you can refer here.


Originally published at https://vtsen.hashnode.dev.

AWS Security LIVE!

Join us for AWS Security LIVE!

Discover the future of cloud security. Tune in live for trends, tips, and solutions from AWS and AWS Partners.

Learn More

Top comments (0)

Billboard image

The Next Generation Developer Platform

Coherence is the first Platform-as-a-Service you can control. Unlike "black-box" platforms that are opinionated about the infra you can deploy, Coherence is powered by CNC, the open-source IaC framework, which offers limitless customization.

Learn more

👋 Kindness is contagious

Please leave a ❤️ or a friendly comment on this post if you found it helpful!

Okay