Click here to Skip to main content
Rate this: bad
good
Please Sign up or sign in to vote.
See more: Java Android file
How to shred a file from external storage beyond recovery, using java code in android?
Posted 5-Jun-13 2:17am
Comments
Prasad Khandekar at 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
good
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.
  Permalink  
Comments
Prasad Khandekar at 5-Jun-13 16:07pm
   
Well put together. +5
Steve44 at 5-Jun-13 16:13pm
   
Thanks Prasad!
suma from bangalore at 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
0 OriginalGriff 245
1 Jochen Arndt 155
2 PIEBALDconsult 150
3 Afzaal Ahmad Zeeshan 120
4 DamithSL 115
0 OriginalGriff 5,695
1 DamithSL 4,591
2 Maciej Los 4,012
3 Kornfeld Eliyahu Peter 3,480
4 Sergey Alexandrovich Kryukov 3,190


Advertise | Privacy | Mobile
Web04 | 2.8.141220.1 | Last Updated 5 Jun 2013
Copyright © CodeProject, 1999-2014
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