A voice recording app for basic demonstration of latest best practices of Android.
targetSDK/compileSDK : Android 10, used flag requestLegacyExternalStorage
for normal storage access. (Android 10 and above requires usage of ScopedStorage and MediaStore) these docs are helpful : DataStorage & Storage Updates
Hilt construction injection and field injection are used wherever required, through the AppModule
, ActivityModule(AcitivityScoped)
, and DatabaseModule
for Room. Hilt Documentation is a good source to get started.
Priamry DataType created for saving voice record is Record
: with basically two properties one title
and other is filePath
linked to the voice recorded file. (third one is the id
as a @PrimaryKey for Room Database)
AppDatabase
extending RoomDatabase
acts as the primary Database, implemented using the RoomDatabase.Callback
for accessing data in background thread using coroutines. A basic guide for the same is this aticle by Ray Wenderlich, but is without DI.
Used new ListAdapter a better version of RecyclerView.Adapter
imporoves use case for working with LiveData and Coroutines, by comparing the data that is already laoded. Beter Explanation here and this article by Ferdinand Bada. DiffUtil
Not all functions need to be suspend type, some tasks are better on main thread (playing/recording audio), while some tasks like accessing data from Database on background thread.
No Services used, the app is intended to work well on the foreground only.
Some other Helpfull links : ViewModels, ViewBinding
Note: Please record at least 3-4 records to efficiently test the application
the first tab/screen is to record our voice from microphone, for which a name is required:
the second screen/tab is the list of our recordings (App only)