This week's book giveaway is in the OO, Patterns, UML and Refactoring forum.
We're giving away four copies of Refactoring for Software Design Smells: Managing Technical Debt and have Girish Suryanarayana, Ganesh Samarthyam & Tushar Sharma on-line!
See this thread for details.
The moose likes Beginning Java and the fly likes Where to store application settings ? Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login

JavaRanch » Java Forums » Java » Beginning Java
Bookmark "Where to store application settings ?" Watch "Where to store application settings ?" New topic

Where to store application settings ?

mandlar suurla
Ranch Hand

Joined: Jun 11, 2008
Posts: 67

If i got some app and i would like to store user's chosen settings, which option would be best? I got only idea to store data in sqlite or use some ini file. Put ini file would be too easy open and see sensitive data like passwords even if i encrypt them.
Bill Cruise
Ranch Hand

Joined: Jun 01, 2007
Posts: 148
Check out the Java Preferences API. You're right about passwords though, those should be stored separately in a database or an encrypted file.
Jeanne Boyarsky
author & internet detective

Joined: May 26, 2003
Posts: 32481

A database is a good choice because it is meant to store organizational information. You would still want to encrypt the passwords of course. I don't think a database is any more secure than a file for passwords though. Anyone with access could still view the encrypted password. Which SHOULD be secure either way because it is encrypted.

[OCA 8 book] [Blog] [JavaRanch FAQ] [How To Ask Questions The Smart Way] [Book Promos]
Other Certs: SCEA Part 1, Part 2 & 3, Core Spring 3, TOGAF part 1 and part 2
mandlar suurla
Ranch Hand

Joined: Jun 11, 2008
Posts: 67

Thank you all for replies and i dont know now which to choose DB sqlite or that Pref API, if the Pref API is faster then I pick that.
Ulf Dittmer

Joined: Mar 22, 2005
Posts: 42958
If this is a desktop app I'd go with the Prefs API. There's no need to start messing with a database just for storing application preferences.
mandlar suurla
Ranch Hand

Joined: Jun 11, 2008
Posts: 67

Yeha i thought same, so i am going to use Pref API
Can't find file where it stores data?
[ July 14, 2008: Message edited by: mandlar suurla ]
mandlar suurla
Ranch Hand

Joined: Jun 11, 2008
Posts: 67

I dont want to make new topic so i use my old one. So i tried to make use of my own configure class but that wasn't good idea. I am going to use pref API, but there is one little problem, as you insert or get the data you need to provide default data, but when i am using same fields in my app many times and in some other classes its like over typing same thing.

So my idea is to use "" empty string for default. If anyone got any good solution, then please help.
I’ve looked at a lot of different solutions, and in my humble opinion Aspose is the way to go. Here’s the link:
subject: Where to store application settings ?
It's not a secret anymore!