Using FXRegistry to store persistent data in FXRuby

46 views Asked by At

I'm using FXRegistry to store the username and password, so that I can authenticate with my web service. When a user logs in, the username and password get written to the FXRegistry, and everything seems great. But when I exit out of the application and run it again, it doesn't seem to be able to ready from FXRegistry. I'm not sure what I'm doing wrong.

Here's the code,

regis = FXRegistry.new(APP_KEY, VENDOR_KEY)
regis.writeStringEntry("USER_CACHE", "username", usrTextField.text)
regis.writeStringEntry("USER_CACHE", "password", pwdTextField.text)

And here's how I read from it,

regis.readStringEntry("USER_CACHE", "username")
regis.readStringEntry("USER_CACHE", "password")
1

There are 1 answers

0
Swaathi Kakarla On BEST ANSWER

So, I finally found out why my perfectly looking code didn't work. It all had to do with the proper way I exited my app. I was using the normal "exit" command to exit out, and it clearly says in the FXRegistry documentation that, "The registry is read when FXApp::init() is called, and written back to the system when FXApp::exit() is called."

So for those of us who don't know how to do that, here's how to do that,

getApp().exit(0)

An example at fxruby.org actually uses FXRegistry to store app data.