I am fairly new to Android development, so I have some questions about Android project/code design.
I know that these questions are somewhat subjective, but I'm interested in how other developers organize their code. Thanks!
Android applications should always be neatly organized with a clear folder structure that makes your code easy to read. In addition, proper naming conventions for code and classes are important to ensure your code is clean and maintainable.
xml: Every project in Android includes a manifest file, which is AndroidManifest. xml, stored in the root directory of its project hierarchy. The manifest file is an important part of our app because it defines the structure and metadata of our application, its components, and its requirements.
When you start a new project, Android Studio creates the necessary structure for all your files and makes them visible in the Project window on the left side of the IDE (click View > Tool Windows > Project). This page provides an overview of the key components inside your project.
A package is basically the directory (folder) in which the source code resides. Normally, this is a directory structure that uniquely distinguishes the android application; such as com. example. app.
Ad packages organization - I develop applications for Android about two years and I have organized source similarly as Andrea Cinesi wrote. But this week I started thinking if it would be more appropriate to package was as application module, for example:
com.example.android
.car
CarActivity
CarListFragment
CarDetailFragment
CarListAdapter
...
.route
RouteActivity
RouteListFragment
RouteDetailFragment
RouteListAdapter
...
.utils
.services
etc.
I'm not yet thinkin twice what all shoul be in "module" (e.g. data entity). But why I'm thinking about this changing? Because in middle or large projects are very much activities / fragments / etc. in one package - and this is confusing to me - I see it especially for larger projects acquired from other developers.
And one more advantage can be divided into module packages - java package-private visibility of methods.
I am not yet decided whether to use this or that variant, but I think for smaller projects do not care and for middle or big project it may be preferable option packages as modules.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With