I'm creating a simple file explorer on Android Studio, and I wonder which one of the following implementations is the best:
I have an activity called MainActivity that displays my list of files, and each time the user clicks on a directory, it creates a new MainActivity (and the onCreate method gets the new list of files, ...).
In a correction from a tutorial, I found that when the user clicks on a directory, instead of starting a new activity, the code keeps the current one and changes everything (clear the list and fill it with new files, change the title...).
Is there a solution that is better than the other ? Is it more efficient to keep always the same activity ?
Thanks for any help.
Keep a single activity no question about it !
When a user clicks an item you build your data-source based on the newly selected path. Make sure to distinct between files and directories. Then simply call notifyDataSetChanged and thats it !
To query the file system there are two ways:
There are many open source projects on github for the subject. Example: