• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

where is app data stored?

 
Greenhorn
Posts: 3
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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 <---
 
Sheriff
Posts: 11343
Mac Safari Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
"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
 
Ranch Hand
Posts: 48
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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!
 
Scott Gains
Greenhorn
Posts: 3
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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.
 
Ranch Hand
Posts: 490
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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 ]
 
(instanceof Sidekick)
Posts: 8791
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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.
 
mohit bahl
Ranch Hand
Posts: 48
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

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
Posts: 3
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
 
Java Cowboy
Posts: 16084
88
Android Scala IntelliJ IDE Spring Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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.
 
Ranch Hand
Posts: 1847
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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.
 
Humans and their filthy friendship brings nothing but trouble. My only solace is this tiny ad:
a bit of art, as a gift, the permaculture playing cards
https://gardener-gift.com
reply
    Bookmark Topic Watch Topic
  • New Topic