简体   繁体   中英

How to run a method only once in Blackberry Java?

I am developing an application in Blackberry. I have to write a code or a method that runs only once. The method does an action on creating the database. Something similar to Oncreate method in Android. Help of any sort is appreciated.

A Y.

Create a singleton class and call the method from singleton class private constructor, or maintain a global flag and check that flag on method call.

There are many other ways but calling of a method is on you, and you can do any way for this.

If you want to run that code in single time of application life then,

use persistent store and add one flag, change the flag value after successfully running that code .

Both BlackBerry and Android provide the Persistent storage.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM