Skip to content Skip to sidebar Skip to footer

How To Have An Activity That Will Run Once Only?

Possible Duplicate: How do I show an alert dialog only on the first run of my application? In my app there will be a Terms and Conditions activity which shows some conditions al

Solution 1:

Why don't you want to use the shared preferences? This would be by far the easiest. Of course you can think of more complicated ways that don't use shared preferences, but you have to store it somewhere. Some messier ways:

  • use a SQLite database
  • use your own file format
  • use a unique device id (careful, Android ID is not really unique) and store it on a remote server
  • store it in a really crazy way, such as a special text message, or a contact, or ...
  • find some way to change your application code (might be possible on a rooted phone?)

To summarize: SharedPreferences is made for this type of thing. It works. Use it. No really.

Post a Comment for "How To Have An Activity That Will Run Once Only?"