Reputation: 4981
Can anyone tell me how can I know if an app runs for the first time on an device? In my app I need to receive some data from a server only when app runs for the first time..
Upvotes: 0
Views: 1589
Reputation: 40193
Agree with Jayp's answer, just want to make it a bit more clear. When you try to get a value from SharedPreferences
, there are two scenarios:
You can try to get value, and if it's not created yet - means your app is being run for the first time. Then you can put a value under this key and next time when you try to get the value - you'll receive the value you've put there. Hope this helps.
Upvotes: 3
Reputation: 822
Boolean flag to SharedPreferences or check if that data already exists in the system and retrieve only if needed.
Upvotes: 6