• After 15+ years, we've made a big change: Android Forums is now Early Bird Club. Learn more here.

Apps form or database? please help! STUCK!

Arhodes

Lurker
Hi all,

a friend and I (both with not much previous coding knowledge) are constructing an app that records details on auto accidents, basically you have an accident / use the app to store details like car make / license plate / etc etc etc.

We have made our app, the layout and all the buttons work perfect! so why am I posting you ask!?!?

well the most important part is something we cannot figure out..

We are looking to make a form where people input their data / move to the next box, and the data STAYS in those boxes if you leave / return to the app, then at a later date all the data can be compiled into an email

the form that I tried doesn't save data.. and the tutorials i've seen on databases are all about storing information rather than being able to store it in a form-style..

Anyone made anything like this before? or able to point me in the right direction as to what I should be learning to make this work?

thanks for your time guys!
 
You can save the data a number of ways

In a database (fast, sercure, robust, flexible, semi-advanced)
In XML (slowish, easy to read, semi easy to code)
As a text file (fast, easy to read (if done correctly), semi easy to code)
as a binanry file (secure, difficult to code)

If you're new to Android I'd suggest any of the 1st three. There are tutorials on all of them online you should be able to find easily :)

If you choose XML though, use the DOM Parser when reading text back in to the app from a file. The SAX parser, (while faster) is much, much more difficult to understand for new coders.

hth!

Edit: moved to app dev forum
 
hmm, if I went the xml way - would that allow me to also pull all the data in to one file also?

And which way would the textfile be?

thanks again!
 
text file would be a sort of "roll your own" solution. Then again so would XML. Or a database heh. Pretty much any of the options require you to decide on a format, and then write the code to put the data into that format.

And yes with XML or text, you could create a file for each data "record" -- in a database, this would be a table row (aka record). Text files can be attached to emails pretty easily (usually). XML should work also but might need some work around to get the attachment part to work. (like renaming it as .html so the email client will allow it to be attached)

For the text you create lines in the file for name value pairs like so:
Code:
customer="John Smith"
license_plate="1234567"
path_to_photo="/mnt/sdcard/somefolder/my_photo.jpg"
For the XML you create nodes for name value pairs like so:
Code:
<record>
    <name>John Smith</name>
    <license>1234567</license>
    <photo_path>/mnt/sdcard/somefolder/my_photo.jpg</photo_path>
</record>
If you've worked with XML and the DOM before, that would probably be the easiest for you.

Performance wise an sqlite db is the clear winner when dealing with many records, when dealing with a single record the text file is probably fastest. But we're talking 100-500 milliseconds difference here. So performance would not really be a big deal no matter what you choose for your app (if I understand what you're trying to do).
 
how do I work around when I really don't want to put ANY info in, I want the user to put their info on.. I just want to create text fields where the data will be written + saved
 
Hmm well you said you wanted the user to send the email at a later date, so you have to save it somewhere in the meantime.

No matter what you do, you need to get the data from the text fields, save it to variables (at least in-memory java variables), and format how you need it, then send or save the data as you need.

There are no magic "forms" in Android. There is nothing that will automatically or magically do this work for you heh :)

You could look at doing a WebView if you are more comfortable working in javascript and the like, but my knowledge of Webviews is limited -- so I cant really advise you as to what the pros/cons are or where the "pitfalls/gotchas" might be.

hth
 
Think of it this way, forms are not "stores" of data. They are just a user interface. The graphical elements a user interacts with. They do not, and cannot, store anything by themselves.

Can I ask what you programming experience is? It might help to know where you're coming from to get a sense of where to advise you.

If this is really throwing you off, you might try looking for a prebuilt solution - such as a Google web form/spreadsheet.
 
as far as coding experience? got 3 days of javascript + xml and now some sql under my belt lol..

luckily I'm a quicker learner - just wish I was a day-quick learner! I have a feeling this might take me a couple of weeks to figure out.

I understand that the input fields are just cosmetic and they don't store the data.. I am more curious as to how to LINK the text fields WITH the data, and vice versa!

I will play about with this stuff though, see if I can't solve it with my friend, cheers for all the speedy responses!
 
Back
Top Bottom