Commit 3030db5
committed
Implement automatic deletion of old screenshots
This change introduces a limit to the number of screenshots stored by the ScreenCaptureService. When a new screenshot is taken, I now check the number of existing screenshots in the app's dedicated screenshot directory (`Android/data/com.google.ai.sample/files/Pictures/Screenshots/`).
If saving a new screenshot would cause the total to exceed 100, the oldest screenshot(s) are deleted to maintain a maximum of 100. Screenshots are identified by the naming pattern "screenshot_yyyyMMdd_HHmmss.png", allowing for reliable sorting to find the oldest ones.
Logging has been added to record the deletion of old screenshots or any failures in the deletion process.
Manual testing is required to confirm this functionality by generating more than 100 screenshots and observing the file system and logs.1 parent becb985 commit 3030db5
1 file changed
Lines changed: 27 additions & 0 deletions
Lines changed: 27 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
332 | 332 | | |
333 | 333 | | |
334 | 334 | | |
| 335 | + | |
| 336 | + | |
| 337 | + | |
| 338 | + | |
| 339 | + | |
| 340 | + | |
| 341 | + | |
| 342 | + | |
| 343 | + | |
| 344 | + | |
| 345 | + | |
| 346 | + | |
| 347 | + | |
| 348 | + | |
| 349 | + | |
| 350 | + | |
| 351 | + | |
| 352 | + | |
| 353 | + | |
| 354 | + | |
| 355 | + | |
| 356 | + | |
| 357 | + | |
| 358 | + | |
| 359 | + | |
| 360 | + | |
| 361 | + | |
335 | 362 | | |
336 | 363 | | |
337 | 364 | | |
| |||
0 commit comments