Welcome to the Official BlackBerry Support Community Forums. This is your resource to discuss support topics with your peers, and learn from each other. New to the forum? Please visit the ‘Getting Started’ link below.
If you want this code to reside within your screen class, you could place it within the onExposed method that runs when your screen becomes visible. You could add some logic in there to ensure that it only runs once since this method can be called multiple times (when a screen is displayed, when a menu or dialog is dismissed from on top of it, etc...).