Jump to content

[TOPIC: topicViewTemplate]
[GLOBAL: userSmallPhoto]
Photo

How to count how many times the application has been opened?
Started by jhoudoris May 07 2018 01:49 PM

5 replies to this topic
[TOPIC CONTROLS]
[/TOPIC CONTROLS]
[modOptionsDropdown]
[/modOptionsDropdown]
[reputationFilter]
[TOPIC: post.html]
#1

jhoudoris

[GLOBAL: userInfoPane.html]
jhoudoris
  • Observer

  • 9 posts
  • Corona SDK

Hi, what feature can I use to count how many times the application has been opened? I saw a video once explaining but I could not find it.

 

I know I could use a .txt file, or json, to read and rewrite, but there should be a easier way to do this. Can you help me?



[TOPIC: post.html]
#2

SGS

[GLOBAL: userInfoPane.html]
SGS
  • Corona Geek

  • 1,867 posts
  • Corona SDK

Why should there be an easier way?  Use a txt file or json or (more tricky but preferable an online server)



[TOPIC: post.html]
#3

jhoudoris

[GLOBAL: userInfoPane.html]
jhoudoris
  • Observer

  • 9 posts
  • Corona SDK

is note there a persistent type of variable that can do this?



[TOPIC: post.html]
#4

SGS

[GLOBAL: userInfoPane.html]
SGS
  • Corona Geek

  • 1,867 posts
  • Corona SDK

A variable is non-persistent by default (as it is instantiated in code) .



[TOPIC: post.html]
#5

jhoudoris

[GLOBAL: userInfoPane.html]
jhoudoris
  • Observer

  • 9 posts
  • Corona SDK

Hello...

 

Thanks for the feedback and consider seeing the example of "persistent variable" that I extracted and adapted from the framework.

 

https://github.com/ipodjms/coronaAppCounter



[TOPIC: post.html]
#6

Rob Miracle

[GLOBAL: userInfoPane.html]
Rob Miracle
  • Moderator

  • 24,742 posts
  • Corona Staff

Using system.setPreferences()/system.getPreference() is a perfectly valid way to deal with this. Depending on the platform, this could be a value stored in a registry style database or a file, but these API calls let the OS deal with it instead of you doing your own file IO, but at the end of the day, it's file IO.  It will save you a few lines of code.

 

Rob




[topic_controls]
[/topic_controls]