Reputation: 535
My app description goes as: We have a large database, which has lots of data (assume it a google server, which has lot of data about every user). We will process data(useful to our app) in another server and store relevant data in app database. The first page of app shows some processed data from database The problem is that, it is not smart to process every single user data and store in app database because every user will not use our app (say every google user will not use every google applications ).
We were planning that when the user install the app, we will process that particular user's data from main database to app database and shows relevant information. Can somebody guide me through this
Upvotes: 5
Views: 506
Reputation: 3506
Try this code:
PackageInfo info = getActivity().getPackageManager().getPackageInfo(YOUR_APP_PACKAGE_NAME, 0);
SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(getActivity());
int lastVersion = prefs.getInt(PreferencesActivity.KEY_HELP_VERSION_SHOWN, 0);
int currentVersion = info.versionCode;;
if (currentVersion > lastVersion) {
// First time launch
prefs.edit().putInt(PreferencesActivity.KEY_HELP_VERSION_SHOWN, currentVersion).commit();
}
Upvotes: 0
Reputation: 1478
I had to face same issue,
I managed it by setting a flag in SharedPreferences
and when next time app comes int to the activity, it checks whether the flag is set or not. If its the first time, it will return false. you can do your codes according to the condition.
//LaunchfirstTimeFlag true, default
if(LaunchfirstTimeFlag) {
LaunchfirstTimeFlag = false;
update in SharedPreferences
// your code
} else{
// your code
}
//SharedPref sample code below.
SharedPreferences preferance = getSharedPreferences(APP_PREFERENCES, MODE_PRIVATE);
SharedPreferences.Editor prefEditor = preferance.edit();
prefEditor.putBoolean("FirstTimeFlag", false);
prefEditor.commit();
Upvotes: 1
Reputation: 112857
On app launch check to see if a file exists, if it doesn't then it is first launch, create the file to indicate that first launch has occurred. In place of a file there are other ways to create a first launch flag on iOS such as NSUserDefaults
, keychain, iCloud Key Value Store, etc.
Note: even though the title states Android the question is also tagged iPhone.
Upvotes: 0