Click here to Skip to main content
13,054,779 members (71,468 online)
Rate this:
Please Sign up or sign in to vote.
How to shred a file from external storage beyond recovery, using java code in android?
Posted 5-Jun-13 1:17am
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

Rate this: bad
Please Sign up or sign in to vote.

Solution 1

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.
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)

  Print Answers RSS
Top Experts
Last 24hrsThis month

Advertise | Privacy | Mobile
Web02 | 2.8.170713.1 | Last Updated 5 Jun 2013
Copyright © CodeProject, 1999-2017
All Rights Reserved. Terms of Service
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100