The method above is OK. It is recommended to use a database to store the number of steps per day. More specifically, it is to store the number of steps per day by time. In this way, the number of steps in any time period of any day can be obtained, providing more expansion.
Save the values of all previous steps with date as the key.
Then get the total number of steps for the day and subtract the previous day's to get the current day's.
The method above is OK. It is recommended to use a database to store the number of steps per day. More specifically, it is to store the number of steps per day by time. In this way, the number of steps in any time period of any day can be obtained, providing more expansion.