• Post Reply Bookmark Topic Watch Topic
  • New Topic

Where to save stuff?  RSS feed

 
Mich Robinson
Ranch Hand
Posts: 260
1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
For a particular game I store user settings and high scores in two files.
Due to all the permissioning issues with Java 7 I changed my jar to a self installing exe.
This makes it much easier to distribute and my little user base is much happier with that.
My problem is the files were simply saved to the same directory that the jar was in but because this is now in the windows program area and I can't save here any more.
Where directory should I save to?

PS I understand that it won't work on Linux and Mac but heyho.
 
Ulf Dittmer
Rancher
Posts: 42972
73
  • Likes 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Does it have to be in files? User settings and high scores doesn't sound like a lot of data - I'd probably use the Preferences API for that (which would require no extra work on OS X and Linux, should you ever go back to a cross-platform approach).
 
Winston Gutkowski
Bartender
Posts: 10575
66
Eclipse IDE Hibernate Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Ulf Dittmer wrote:Does it have to be in files? User settings and high scores doesn't sound like a lot of data - I'd probably use the Preferences API for that...

And another way might be to store them in a database. I'm pretty sure that "mini" dbs like JavaDB and Derby can simply be included in the jar, but I'm not sure of the exact procedure.

Winston
 
Mich Robinson
Ranch Hand
Posts: 260
1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks for the instant reply Ulf.

The data is very small, about 20 char for the settings and about 500 char for the high scores. It would be great to use some inbuilt storage method. I did try a method similar to this that was supposed to store data in cookies but after a few days of getting more and more frustrated I gave up and just resorted to using files. I'll see if I can master this new API - it actually looks quite simple!

Many thanks

Mike
 
Mich Robinson
Ranch Hand
Posts: 260
1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Winston Gutkowski wrote:
Ulf Dittmer wrote:Does it have to be in files? User settings and high scores doesn't sound like a lot of data - I'd probably use the Preferences API for that...

And another way might be to store them in a database. I'm pretty sure that "mini" dbs like JavaDB and Derby can simply be included in the jar, but I'm not sure of the exact procedure.

Another interesting idea but the data I'm storing is not complex. I've used SQLite before and found it quite useful though I haven't used JavaDB. I might actually have a look at this for a few other little projects I have on the go. Thanks.
 
Ulf Dittmer
Rancher
Posts: 42972
73
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Winston Gutkowski wrote:And another way might be to store them in a database. I'm pretty sure that "mini" dbs like JavaDB and Derby can simply be included in the jar

The DB code itself can be included in the jar, but since the data is supposed to be persistent across restarts, the DB needs to store it in files somewhere - which would mean it's back to square one.
 
Mich Robinson
Ranch Hand
Posts: 260
1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Just to say that the Preferences suggestion was remarkably easy to use and implement (not always my experience with Java). Cheers.
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!