aspose file tools*
The moose likes Beginning Java and the fly likes where is app data stored? Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "where is app data stored?" Watch "where is app data stored?" New topic
Author

where is app data stored?

Scott Gains
Greenhorn

Joined: May 31, 2006
Posts: 3
Hi all...I'm learning java this summer by creating a desktop organizer for myself BUT...I don't know how application data is stored.

What is the standard way that programs save data between running's (contacts, notes, etc)...what kind of format/organization of files do programmers usually use for this kinda of user data??

This is really my missing piece of the puzzle,
THANKS!!
Scott <---
marc weber
Sheriff

Joined: Aug 31, 2004
Posts: 11343

"scott lastname,"

Welcome to JavaRanch!

Please revise your display name to meet the JavaRanch Naming Policy. To maintain the friendly atmosphere here at the ranch, we like folks to use real (or at least real-looking) names, with a first and a last name.

You can edit your name here.

Thank you for your prompt attention, and enjoy the ranch!

-Marc


"We're kind of on the level of crossword puzzle writers... And no one ever goes to them and gives them an award." ~Joe Strummer
sscce.org
mohit bahl
Ranch Hand

Joined: Mar 22, 2006
Posts: 48
hi Scott

Firstly I will suggest you to change your display name according to the JavaRanch naming policy.

About your question now.

* As you are learning java then you will defiantly study about file handling. Files are a basic way to persist your application's data. You can decide any format in which you will be putting data in your file and when your application starts you can read all this information and keep it in your application in some objects (class you will have to define according to the information you will save). And when your application closes you can write back all this information (which might have been modified) back to the file.

* Another way is that you can use xml files and keep the information in a structured way. Reading and writing information can be done using the xml related APIs.

* But if you want to go a little further you can use a database which might be available on your system, like MS Access, etc or for that matter you can use MS Excel too. You can make a table structure and read and write information into the database. For this you will require to go through JDBC APIs.

Hope this helps

cheers!


to err is human, but the company policy doesn't allow it!
Scott Gains
Greenhorn

Joined: May 31, 2006
Posts: 3
Thanks for your responce!

I was reading up on XML this morning and considered that as a way to store my data; although I'm thinking that it might be a bit overkill.

I was also considering (originally) to just use comma separated data stored in a file, but I thought that there was a more elegant way to store data that is to persist.

I also considered a DB but because I'm still new to Java I think I'll save the DB option for later by extending my program to read from a server or something.

As far a reading/writing from files is there an elegant format(ie. how does Microsoft address book store their info?)???


Thanks a bunch.
Rusty Shackleford
Ranch Hand

Joined: Jan 03, 2006
Posts: 490
I am not sure how MS stores the data in the address book, and you might not want to emulate MS.

Here are two ways for simpler data schemes(ie things that would be overkill with a database). You can either directly implement file IO, which you need to learn anyway, or implement the Serializable interface. If you are asking "What is an interface" you aren't ready for that quite yet. If you have a relatively decent grasp on console IO, either though the Scanner class, or java.io package, file IO should be pretty straightfoward to you.
[ June 01, 2006: Message edited by: Rusty Shackleford ]

"Computer science is no more about computers than astronomy is about telescopes" - Edsger Dijkstra
Stan James
(instanceof Sidekick)
Ranch Hand

Joined: Jan 29, 2003
Posts: 8791
Rusty mentioned interfaces. If you're cool with how those work, you might make a data storage interface that can have multiple implementations. For example, on one project I made a DataStore interface with simple methods like get(key), put(key,value), delete(key), list(). The first implementation used a HashMap in memory, which was enough for me to test some repository functions even though it didn't really persist from one run to the next. The next implementation used flat files and still works plenty well enough. A future one might use another file format or even a database. What's neat is I can swap one out and another in without changing any other code.

There's a cool design concept called "deferring decisions". This interface idea lets you defer chosing a final data storage technique until you have everything else working. And if you thought this had to be one of your first decisions you would not be alone.


A good question is never answered. It is not a bolt to be tightened into place but a seed to be planted and to bear more seed toward the hope of greening the landscape of the idea. John Ciardi
mohit bahl
Ranch Hand

Joined: Mar 22, 2006
Posts: 48
As far a reading/writing from files is there an elegant format (ie. how does Microsoft address book store their info?)???


I am not very sure how MS address book does it. Possibly MS also has a file underneath but they are quite good at hiding things.

Anyways, as I suggested earlier you can decide the format as you like. You can even have multiple files to stored information in a distributed way or have all the information in one file with a pre planned format like

name, birthdate, contact, address, .....
mohit, 12_Nov, 2245324, .....

one row having all the information of one person.
Just try to keep I/O interactions to a min to increase efficency. As the application starts read the entire file into objects and save them for later use in the application and on close of application write it back to file (repeating myself here )

cheers!
mohit
To err is human, but the company policy doesn't allow it!
Scott Gains
Greenhorn

Joined: May 31, 2006
Posts: 3
Thanks for all your feedback.....

So I think that I've narrowed it down to CSV or XML as both are supported by java so it should make things a tad easier than coming up with my own format.

THanks again
Jesper de Jong
Java Cowboy
Saloon Keeper

Joined: Aug 16, 2005
Posts: 13875
    
  10

If you want to learn about databases, study the JDBC API. There is a JDBC Database Access Tutorial on Sun's website.

If you want to learn Java because you want to become a professional software developer, it is certainly worth the effort to learn how to use databases and JDBC, because databases are very common, especially in business software.

If you're writing an application like a desktop organizer that needs to store data for the application alone (i.e. there are no other applications that need to access the data), you could use an embedded database: a small database that runs "inside" your program, instead of having separate database server software running on your computer. There are a few nice and free embedded databases available for Java, such as HSQLDB or Derby.


Java Beginners FAQ - JavaRanch SCJP FAQ - The Java Tutorial - Java SE 7 API documentation
Scala Notes - My blog about Scala
Jeroen T Wenting
Ranch Hand

Joined: Apr 21, 2006
Posts: 1847
The Windows address book uses a custom dataformat. I don't know where it's stored now, but I did write something to read the file in Pascal something like 10-15 years ago and it wasn't hard.

It's no different from any other application that defines its own datatype, which is a good way to work for storing data that doesn't need to be portable to other applications.


42
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: where is app data stored?
 
Similar Threads
Back to basics with HttpSession
Restrict JSP Page from Database Values
Serialization Doubt
How Do the Table came into Picture
Retrival of data stored as object