-2

I wonder how to:

Show an alert every time the User start the application.

When User select the option. "do not show again." how not to show more? where to save this information without the database? is easy?

How Do I? I have saved in the cache when the option was selected? I do not understand quite yet. thank you very much

Thanks

GDawson
  • 3
  • 1
  • 6

3 Answers3

0

Do it in First screen's onCreate() method...

well for maintaining its state.. create a class and keep a variable and create static getters and getters for that.. set it when he says dont show me again.. and check every time before showing..

ngesh
  • 13,398
  • 4
  • 44
  • 60
  • more how do you not show more alert when this User select the option that no longer wants to see. Example: "do not show again" – GDawson Apr 13 '12 at 11:05
0

you could record when the user starts your app in onCreate() and then only display the alert if this isn't set. So, something like this.

public class MyClass extends Activity {
    boolean alreadyOpened = false;
    boolean doNotShowAgain;

    public void onCreate(Bundle savedInstanceState) {

        doNotShowAgain = loadFromPreferences();

        if(!alreadyOpened || !doNotShowAgain) {
            showDialog(MYDIALOG);
            alreadyOpened = true;
        }

        //your code goes here

    }

}

Then you need to write the code to load the "no not show again" preferencemore

Mike T
  • 4,747
  • 4
  • 32
  • 52
0

You can use shared preferences following is the code to store data in it

    SharedPreferences prefs;
             prefs= this.getSharedPreferences("yourprefName",0);
        Editor editor = prefs.edit();
                 editor.putString("yourtag", "information");
                 editor.commit();
and Get information like 
String info=prefs.getString("yourtag", null);

for more information How do I get the SharedPreferences from a PreferenceActivity in Android? and this one

Community
  • 1
  • 1
Nitin
  • 1,966
  • 4
  • 22
  • 53