Search This Blog

Thursday, May 9, 2013

Get the number of times app is used

 private SharedPreferences mPref;
public static final String PREFS_NAME = "YourPrefName";
int c;

in onCreate() write the following

  mPref = getSharedPreferences(PREFS_NAME, Context.MODE_PRIVATE);
c = mPref.getInt("numRun", 0);
Log.i("TAG", "Number of count of open App:" + c);
mPref.edit().putInt("numRun", c).commit();
Log.i("TAG", "Number of count after commit of open App:" + c);

No comments:

Post a Comment

Note: Only a member of this blog may post a comment.