My app gives 200 coins on the first installation. A user can use these coins to perform an action in an application. The number of coins is stored in the SQLite database and can be changed. If you uninstall and install the app number of coins returned (Becomes again 200 coins)
I do not want users to reinstall the app when they have 0 coins and return the original number of coins
I tried to write down the database in the SD card. But what if there is no SD card and what if the user gets access to the database and can change it?
So maybe I can check was app installed before?
Or how I can solve this problem another. So my application works without the server part
First of all, you should know that even if you can detect the application has previously installed on their device, they can simply format their phone.
Then how do I solve this problem?
You should have an online database that stored the users coin. Why? Because no matter how many times the users reinstalled or format their device, they can't alter the coins.
You can still use SQLite as your database for your application. Just simply store the coins seperately.
Just to check if app was installed on the device before or not, you do not need to write the whole database on the sd card.
Secondly , you will write on the internal storage and not on the SD card.
It does not matter if SD card is present or not.
Now , just to check whether app was previously installed or not on the device you can do the following :
When app is first time installed on a device, create a folder named temp or any name which a user will ignore.
Now whenever the app is run, you can simple check whether that folder exists or not ? If that folder exists means the app was already installed if that folder does not exist, means this is the first time the app is installed.
Instead of creating a folder you can also create an empty file and check if the file exists or not.
Let me know if you need some more help.
Related
In my Android app, the user can select a folder thanks to Intent.ACTION_OPEN_DOCUMENT_TREE
I can then write files to this folder.
The problem is that the user can delete this folder or remove the permission to access it.
In both cases, I would like to display a message to explain the user what is happening and how to fix this issue.
I need 2 different messages and so I need to differentiate these 2 cases
I wanted to use DocumentFile.exists() but it returns false in both cases.
How can I do that?
I'm using the following line of code in flutter/dart to make sure that the files that my app creates here aren't visible to the end user. These files have uid's for names and are crucial for the app to operate so I don't want a user to be able to delete them. Am I using the correct function here?
import 'package:path_provider/path_provider.dart';
Directory appDocDir = await getApplicationDocumentsDirectory();
I think that is your best bet. But it's still the users phone and if she is clever enough, anything can be removed (jailbroken, rooted, etc..)
The idea is that only the app can access files there. On Android it returns an internal system-wide folder with a specific folder within that only your app can write to. No other app or user can.
If UIFileSharingEnabled is activated in the Info.plist file for an app, then the user can delete files. Other than that, I think the same applies for iOS phones, that the sandboxed environment with the returned directory only is accessible by the app itself and not the user.
I want to restrict my application to install only allowed device. That is while installing the app I want to fetch the device information like imei number. Then I want to check the imei number if it is valid or not using my restored database of imei.
Is that possible?
Its not possible to prevent App installation, if one has the APK file but
Through smart coding you can achieve it
1) Anyways you will get the IMEI numbers of the users phone so programatically you can check the condition on landing/splash page if IMEI==USER_IMEI_NUMBER then only he/she can able to see its main page else he will not get authority to enter into main page but for that you need to create APK file for each device
2) If you dont know how many users will use your app then you can do remote database in that database you can save new users IMEI number and in splash/landing page you can check through webservice that IMEI==USERS_IMEI_NUMBER (from remote database) then he/she can use your app but off course for that you need to mention internet permission in it and user must have valid internet connection if you dont want user to check it identity/IMEI number each time then you can validate user at once and you can save its result in shared preferrences and you can give access to user everytime without hiting webservice for validation
hope this suggestion may help you happy coding :)
I would like to know how can I prevent my users from deleting an image from the internal storage (for example, a photo) before it gets uploaded to the server.
I am using Firebase as my backend, and every works fine. But, if the user deletes the image before it can get uploaded (this happens because if there is not the internet I resume the upload once the user phone connects to the internet) my app crash because the route does no exist.
And I know I can check if the file exists, and do something else, but, since people is uploading important information, a placeholder will be not an option.
Thanks in advance for your help.
How do I figure out, if an app is loaded for the first time after it has been downloaded. I mean when the app is first bought/downloaded from market, how will I figure it that this is the first time(never has been run on this phone) this is going to run hence I can throw up some registration activity?
yeah, I thought of declaring a table which is checked to see if it has any rows. If there were rows then this was because it had been loaded and we inserted a row.
But I want to avoid this, is their any API which can tell me that the user had used this app before on this phone?
Android has API to store preferences.
You can store a flag in SharedPreferences, read about shared preferences
You can have a flag that you track, i.e. isFirstTime. Have a check in your main activity:
if(isFirstTime)
// do registration
isFirstTime = false;
You can save the value in between executions as a shared preference. See Data Storage documentation for details on how to do that.
Write a property somewhere that persists on the first load and check for that on every load, if it is there then you know that it has already been loaded once. Or you might even just make it a load counter and maybe you could use that information as a statistic (report back some where)
every application has it's own directory for data (/data/data/).
just write an empty file there and check for it every time you start an application
I don't know of any Android Market API that will tell you if the user downloaded/used the app before.
I think that you'll have to do it yourself which gives you two choices to persist data across an app uninstall/reinstall cycle:
(1) save a file on the SD card an check that to see if the app was installed before or
(2) contact a server with some user specific info to check if it was downloaded/used before.
The problem with the SD card method is that its not effective if the user erases the file or switches SD cards.
For the server model, you'll need to have a server to record some piece of information like user id or device id or some mix.