I just want to know is there any syntax to trigger the internal dark mode of the mobile, I know that I should used SharePreferences to save the Darkmode status in my mobile, but All I want is, is there any function to trigger dark mode into my whole mobile views, not just the app that I've been created. What's the best way to implement darkmode? it is sharedPref?
Instead of clicking that darkmode manually on settings, I want to trigger darkmode through my app button, is that possible?
I just tried this but the result, it is only triggered dark mode just in my app only, not on to the entire mobile. I appreciate any help.
AppCompatDelegate.setDefaultNightMode(AppCompatDelegate.MODE_NIGHT_YES);

Moving to the Dark Side: Dark Theme Recap
Offical Documents by Yaroslav Berezanskyi
Levels of control. Backward compatibility
There are 3 levels of control for Dark Theme:
1. System Setting:
It’s a global setting which is controlled by the user either explicitly or implicitly (by toggling the Battery Saver mode).
There are a limited number of ways to change it:
This setting is applied on the system level including all the system UI and applications. Once the setting is changed, your application gets Application.onConfigurationChange callback and all activities are immediately recreated. However, it’s up to your application to either follow it or override with a local one (application or activity wide setting).
2. Application Setting:
As a good citizen, you can let the user choose between themes inside your app (overriding the system setting).
It’s to be controlled using AppCompatDelegate.setDefaultNightMode API via your custom widget (usually, it’s ListPreference in your settings screen).
The recommended options are:
Furthermore, you can set Light as the default and hide the last 2 options for API below 21 since none of them are supported.
Each of the options maps directly to one of the AppCompat.DayNight modes:
Once the setting is changed, all started activities get recreated (or get Activity.onConfigurationChange callback, if you opted-in in the manifest to handle the configuration change manually).
3. Activity Setting:
It’s very similar to the application setting, but applies to a specific activity only using getDelegate().setLocalNightMode. Be aware that any call of it triggers an activity recreation (if the theme changes). As Chris Banes suggested here, you should prefer AppCompatDelegate.setDefaultNightMode over it since it minimizes unnecessary recreations.