• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

RecordStore instances and destroyApp()

 
Greg Schwartz
Ranch Hand
Posts: 132
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
A recent article on wireless.java.sun.com stated:
Each RecordStore instance tracks the number of times it has been opened. The record store is not actually closed until closeRecordStore() has been called the same number of times.

If an application is closed (i.e. destroyApp() is called) while a record store is still open, is the record store still considered open the next time that app is launched?
 
Michael Yuan
author
Ranch Hand
Posts: 1427
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I suspect the answer is no. But why don't you try it and let us know.
 
Blake Minghelli
Ranch Hand
Posts: 331
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Originally posted by Greg Schwartz:
If an application is closed (i.e. destroyApp() is called) while a record store is still open, is the record store still considered open the next time that app is launched?

I found this to be true at least with the emulator provided in Sun's Wireless Toolkit. I opened a RecordStore, closed the app, and then restarted the app and tried to delete the RecordStore. I got an exception complaining that the RecordStore could not be deleted because it was still open.
This seems like a weird behavior to me. It especially seems odd that you have to call closeRecordStore() as many times as you called openRecordStore(). According to the docs, if you call RecordStore.openRecordStore() and the store is already open, then you get a reference to the open store. So why is there some kind of a weird mechanism that says "even though I'm going to return a reference to this RecordStore that is already open, I'm going to keep track of how many times someone has called this method."
Anyone else think that's weird or have an explanation. Maybe it has something to do with the fact that a RecordStore can be shared among MIDlets?
 
Greg Schwartz
Ranch Hand
Posts: 132
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I definitely found that to be a strange behavior as well. It doesn't seem logical to have to call closeRecordStore for each openRecordStore. I'm not sure if I agree, however, about the RecordStores staying open after destroyApp() is called. I'm finding that RecordStores are all closed when the application re-starts. If anyone has any additional information on these items, please let us know.
Thanks!
Greg
 
It is sorta covered in the JavaRanch Style Guide.
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic