0

My application is downloading books (zip) through in-app purchase.

I want to ask that is there any way in android which allows to store these books with security in SD card or external storage so that no other file manager can delete it ?

Any help would be appreciated.

MohK
  • 1,873
  • 1
  • 18
  • 29
  • 1
    http://developer.android.com/guide/topics/data/data-storage.html (search for "private") – shkschneider Apr 24 '14 at 10:12
  • 1
    by default android external storage is world-readable and hence can be read/deleted by other applications and users. The only way to save it securely is to save it in internal storage which only the application can read. but that is also accessible if the phone is rooted and hence is modifiable. – madteapot Apr 24 '14 at 10:20
  • but i want purchased books back if user reinstall the app. which is not possible by internal storage I think. :( – MohK Apr 24 '14 at 10:22

2 Answers2

1

Files saved to the external storage are world-readable and can be modified by the user when they enable USB mass storage to transfer files on a computer.

Source: http://developer.android.com/guide/topics/data/data-storage.html#filesExternal

So you can't store any data on sd card as you want nobody can delete them. But you can use internal storage:

By default, files saved to the internal storage are private to your application and other applications cannot access them (nor can the user). When the user uninstalls your application, these files are removed.

Source: http://developer.android.com/guide/topics/data/data-storage.html#filesInternal

krossovochkin
  • 12,030
  • 7
  • 31
  • 54
  • Thanks for help, but what if user uninstall and reinstall the app , internal storage files are deleted as per my knowledge when uninstall. So he has to re purchase the book. what to do? – MohK Apr 24 '14 at 10:33
  • 2
    The exact solution for this: in your application should be a way to "restore transactions". Look here: http://stackoverflow.com/questions/16871115/restore-transaction-inapp-purchase-android So if user uninstall and then install your application again, you check if user purchased some stuff, and download it again if so. That's it. Also this will work if user install your app on another device – krossovochkin Apr 24 '14 at 10:56
  • hey that sounds nice. I'll definately try it. – MohK Apr 24 '14 at 11:07
0

To write to the external storage, you must request the WRITE_EXTERNAL_STORAGE permission in your manifest file:

 <manifest ...>
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
...
</manifest>

for more details click here

Android dev
  • 273
  • 2
  • 5
  • 23