Here’s what I remember from decades gone by:
If you delete a file, it is “moved” to the “recycle bin”.
A directory (or folder) entry is a record in the directory containing the metadata of the file - name, size, date written, updated, start sector (track, block, platter) of the file.
Each sector on the disk contains the data for the file, and if there is more data, a pointer to the next sector in the file. The last sector contains an “End of file” marker.
(This is another source of insecurity, In the good old days, the sector was only written to the end-of-file marker, and there could be data from a previous file in the remainder of that sector; if say sectors are 10K and your file ends at 3K, there’s 7K that could be a fragment from a previous erased file)
At one time, in FAT file systems, and DOS, deleting a file simply put a “~” in the first character of the filename, indicating the entry in the folder was now free to be reused.
(A folder is essentially just another file - a chain of sectors containing filename entries. If the current sector is full, extend the folder chain to a new sector to add more files. this is also the advantage of the “~” marking an unused folder entry; the next file you write in that folder will use the next empty space, so the directory does not grow uncontrollably as you delete and add. )
there is also a sector table, indicating which sectors are actually free - ie. not part of a directory or file.
So a corresponding entry for the “deleted” file is created in the directory called “Recycle Bin”, pointing to the first sector of the file data, plus metadata of where the file was erased from, in case you want it restored. The chain of data remains intact. Your file is recoverable, but from what you can see from Windows, it is “free space”.
Should the disk run out of actual free space, there is an Operating System algorithm to decide which files in the recycle bin get used in what order. (oldest first?)
Otherwise, the files are there until you “Empty Recycle Bin”. Then, the entry in the Recycle Bin folder is now marked free to be reused; the data chain for the file is marked as free space in the sector table. When the data disappears (answer to OP) depends on how much data is written to the disk, how often and how fast.
The operating system does not necessarily overwrite any data automatically. Worst case, you “erase all” (DEL . ) and in the root of the disk system all files are marked as deleted, all sectors marked as free. If nothing further is written to the disk, an enterprising data recovery tech can get almost anything back.
(This is based on FAT technology. Not sure what refinements NTFS or assorted Linux filesystems have come up with. Computers are sufficiently faster and have so much more space than the Good Old Days so OS’s are often tweaked for speed and security.)
A few notes -
Writing a new file involves putting the necessary entry (or updating the entry) in the directory. Then the blocks of data are written in sequence; as each new block needs to be written, an OS algorithm decides with free sector to add to the new chain of data.
Except for databases (with pre-allocated data space, usually) a lot of “File - Save” usually involves writing a new file, delete the old then renaming the new file. This way if the write fails, the old file is till intact. So it involves writing extra data.
A USB stick (AFAIK) works the same, except sometimes the recycle bin is on the stick too, so the whole system is self-contained. If there is no recycle bin, then deleted files go straight to sectors marked “free” and directory entries marked as deleted. But again, deleted data is still actually on the disk.
Some security options in filesystems will erase data when deleted, but generally they don’t. no need to.
SSD (and sometimes, USB sticks - nonvolatile RAM in these devices have a very large but finite number of write cycles before they stop working, so the hardware includes algorithms to allocate writes to least use sectors so no sector is overused with writes. Again, this helps preserve sectors full of deleted data, and auto-erasing data sectors simply halves the lifetime of the device, so less common. Note your phone also contains NVRAM.
I don’t know how recoverable data is if, say, a recovery program finds a few framents of a file but not the whole thing. Text files - obviously. Word files and email files are usually text with plenty of extra control data. Spreadsheets - usually, you can decode a series of cells. I have no idea how recoverable a chunk of a JPG is. It depends how important this is to whoever is looking. the point is, each sector that is not blanked out point to the next in the chain, so a decent sized fragment chain can be identified as a single file for analysis.
This is why there are eraser programs that go through and erase all empty sectors and end-of-file space. Some will also clean deleted directory entries (Since file name, size, and date may be sensitive info too)
the first step in forensic analysis is to make a sector by sector mirror of a disk so it can be analyzed without destroying the original