4

I need to have a trial period (7 days) in my application. From this I came to know that you can do that by keeping permanent file, database or shared preference.

Where do I keep that file so that the user isn't able to see/delete it.

If I put that logic in Sharedpreference or a file with a path "data/data/packagename", when the application is uninstalled then all history will be lost.

Any other workaround/ideas?

Note: there is no server, application works locally with no Internet.

Community
  • 1
  • 1
Mohammed Azharuddin Shaikh
  • 41,633
  • 14
  • 96
  • 115
  • possible duplicate of [Can I store data on an Android device to persist between installs?](http://stackoverflow.com/questions/7107673/can-i-store-data-on-an-android-device-to-persist-between-installs) – Krishnabhadra Jun 06 '12 at 10:12
  • I don't think there is a dependable option present in android to store data across installation (If you are not using network). – Krishnabhadra Jun 06 '12 at 10:26

3 Answers3

1

I would say a better workaround would be encrypt your file and then store it in a random place. This way, even if the user has the access to that file, he/she is least likely to tell it's purpose and delete it anyway. And Android has great support for encryption as well.

Have a look at these to get you started:

Android Crypto Implementation

Android Developer: Crypto Package Summary

Orlymee
  • 2,349
  • 1
  • 22
  • 24
Kazekage Gaara
  • 14,972
  • 14
  • 61
  • 108
0

You can store as hidden so no chance to delete by user

see this

Community
  • 1
  • 1
MAC
  • 15,799
  • 8
  • 54
  • 95
0

I would say, make the application's data which can't be cleared from manifest like this:

android:manageSpaceActivity="YourStartingActivity" 

in application tag.

Now place the application in database or application folder. This solution will save you from clearing application data. Now for uninstallation issue. Make a broad cast receiver which triggers when any application is uninstalled from the device. Once user will try uninstall your application you can catch it through receiver and prevent it. This broadcast receiver can be in a separate class like Watcher class which will be installed with your application. You can do it easily. There are many examples.

Awais Tariq
  • 7,724
  • 5
  • 31
  • 54
  • My concern with this will be that you are preventing uninstall of an application which is against user wishes. So with this approach you are likely to alienate the user to your application and your brand on a wider scale. it is important that the user shall not be allowed to use the application beyond the tiral period but prevent uninstall is not a good choice. – Orlymee Jun 06 '12 at 10:52
  • Then I would suggest you to keep record of devices in which your application is installed. On start check the expiry from your server, even a single csv keeping record of device id's with installation date. But obviously you need internet connection to do so. – Awais Tariq Jun 06 '12 at 12:20