0

In my app there are 2 activities : 1st MainActivity (Home Activity ) and 2nd GameActivity (There is editext in MainActivity which allows user to enter KEY to open GameActivity).

I provide user a unique KEY free for the first time , with the help of it , user can open GameActivity for the first time . Second time user has to buy another KEY to open GameActivity (That means to open GameActivity , every time user needs a different KEY ). If user uninstalls my app , I want to save that key (Free KEY provided by me earlier ) in the internal storage .

So that if the user installs my app again , it will be checked if there is a KEY in internal storage of the device , if yes then it will be notified to the user that you have already used this KEY before so buy another KEY . If no , then it's OK.

If you didn't get something please ask me . Please HELP me . Request

2 Answers2

0

I think you can not do that. You shouldn't force the users to keep data on their phones without their consent.

Follow this topic: Android: Save file permanently (even after clear data / uninstall)

Community
  • 1
  • 1
xxx
  • 3,315
  • 5
  • 21
  • 40
  • I know . But actually I am preventing user from using the previous Free Key provided by me. Otherwise , user will keep on uninstalling and installing app and will play the game every time for free – Dhoni Singh Jun 21 '16 at 19:14
  • Have you thought about adding simple login system with firebase? Then make them create an account to play. – Jay Jun 21 '16 at 19:22
  • Another way is you can simply use a webservices, You will save the Key + user's device ID on your database on server (because every device has its ID), and then the user reinstall your app, just make a request from application to your server for authentication. – xxx Jun 21 '16 at 19:22
  • @LikeWhiteOnRice , can you show me the steps how to use firebase ? – Dhoni Singh Jun 21 '16 at 19:31
  • @HuyNguyen Please tell me procedure how to use webservices – Dhoni Singh Jun 21 '16 at 19:32
  • @DhoniSingh It's not a simple knowledge to learn in one day, You should try to learn with example, something like: http://www.androidhive.info/2012/05/how-to-connect-android-with-php-mysql/ Then you can find more by Google, Youtube with keyword: "connect Android with PHP & MySQL". That's is the first step for you :) – xxx Jun 21 '16 at 19:36
  • @HuyNguyen Thanks for providing me essential links – Dhoni Singh Jun 21 '16 at 19:40
0

Their are various way of doing that, but online. I will suggest to don't go for any offline saving solution. The best way is just send your device id to your server, if the server has the device id then it will return error, other wise it will store the device id in the database and return the free key. So either your app uninstalled the server still has the device id, that will make sure that user will not get any more free key.

Hope it will help :)

Neo
  • 3,546
  • 1
  • 24
  • 31
  • Looks nice solution , but can you show me some codes or some tutorial to link my app online to server – Dhoni Singh Jun 21 '16 at 19:39
  • Are you using any server for your application. – Neo Jun 21 '16 at 19:40
  • If you are not using any server, then better to go with parse, https://parse.com/docs/android/guide. Here you can create a table of device id and boolean with default false value. On every launch just query with your device id, if it returns false then make a free key available and again save a true value with the device id. So for next time it will return true that means user have already availed their free key. Hope your problem is solved, kindly accept the best answer :) – Neo Jun 21 '16 at 19:50
  • Thanks Neo for the link , I am working on it , the moment I find my app is working the way I wanted , I will accept your answer . – Dhoni Singh Jun 22 '16 at 05:30
  • Android 10 (API level 29) adds restrictions for non-resettable identifiers, which include both IMEI and serial number. Your app must be a device or profile owner app, have special carrier permissions, or have the READ_PRIVILEGED_PHONE_STATE privileged permission in order to access these identifiers. – Abhijith Brumal Feb 16 '22 at 06:42