Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Intent in android to tell the app if it is installed first time

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

like image 216
user3265443 Avatar asked Nov 11 '22 13:11

user3265443


1 Answers

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();
like image 168
Jithu Avatar answered Nov 14 '22 22:11

Jithu