tags:

views:

59

answers:

3

how we can save a file as temporary basis

i have a xml file it is in encrypted mode i want to decrypt it .but i want it doesn't save on disk rather it save on flash memory. after decryption i have to read values and then it should destroy(decrypted xml file).

+1  A: 

Why not just decrypt it in memory and after use you "destroy" the area of memory it occupied? (Write over with random values).

Sani Huttunen
Probably the best approach. However, it it still theoretically possible that your app gets paged out at the critical time, resulting in the decrypted state being written to disk. It is really difficult to be absolutely sure that this never happens.
Stephen C
+1  A: 

In general, you can not guarantee that the decrypted file will not be written to disk.

emory
+1  A: 

You can use one of the File.createTempFile(...) methods and make sure that it's deleted as soon as it's not needed. You can also set File.deleteOnExit() .

But, as others have posted, there is no guarantee that the file will not be written to disk.

dragisak