Click here to Skip to main content
15,885,546 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
How to shred a file from external storage beyond recovery, using java code in android?
Posted
Comments
Prasad Khandekar 5-Jun-13 7:27am    
Hello Suma,

How about deleting the file first then creating a new one with same name with lot's of random contents and deleting it. Repeating this may be 2-3 times should make the file unrecoverable. It's just an idea.

1 solution

Securely deleting files usually requires direct access to the filesystem and underlying storage driver because write/erase behavior is different for the underlying storage medium (e.g. writing to a file on a HD is significantly different from writing to a Flash-based medium).

On a HD it might be sufficient to open the file, write to it random data and then delete the file.

Especially for Flash-based media you don't have any guarantees, when a block is actually erased unless you can directly access the driver and force it to erase the block that previously contained the file.

If you don't have driver access, you can try to force an erase on a flash medium by these steps:
delete the file

The blocks used by the file are marked as no longer in use,
but their contents is still on the medium. Even writing to the file would not help, as the modified blocks are not replaced in-place, but put elsewhere on the medium.
Create a new file and write to it until the whole medium is filled

As the medium fills, the unused blocks are collected and erased to make blocks available for the growing file. When the medium is full, the blocks containing the deleted file should be erased and overwritten. The actual behavior is dependent on the driver implementation and the flash controller in use, so these steps are likely to force the block to be overwritten, but there are no guarantees.

The other downside of this approach is the time required to fill the medium.
 
Share this answer
 
Comments
Prasad Khandekar 5-Jun-13 16:07pm    
Well put together. +5
Steve44 5-Jun-13 16:13pm    
Thanks Prasad!
suma from bangalore 6-Jun-13 0:37am    
I am sorry steve44, I dint get you properly.If you help me in giving small code in java android then it will be very useful.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900