Java & Database android app

Thread Starter

geoffers

Joined Oct 25, 2010
487
Hi all,
I'm trying to get my head around using java!
I've used python a few times but only in a really dirty sort of a way.....
Other than that all of my programming for the last 20 odd years has been mpasm so be gentle.
I've moved my asm from absolute and procedural to a more 'object' sort of programming so am think in a more oo way than I used.
That's the background here's the question, I've used SQL lite in the past to create database of sheep parentage to avoid inbreeding etc. I want to be able to handle more information about my animals, say for example milk production in the cows, weight gain for young stock .
This ends up as a lot of data, ie, twice a day for a cow in milk, its easy to save this data in a text file.
Is the best way to save it in a database to save the name of the text file and use this to point the program to the text file?
Or is there a better way, maybe save a list as a database entry?
I'm using java as I want ultimately to write a android app to handle this (my android book says everything in android is saved in a database...)
Thanks Geoff
 

ArakelTheDragon

Joined Nov 18, 2016
1,362
I am not that good at Java.

How are you going to use this information? Is it only for storing or for other purposes as well? If your book says so, it might be better.
You are making quite a leap, it will take some reading about high level languages.
 

Thread Starter

geoffers

Joined Oct 25, 2010
487
Thanks,
I've spent quite a lot of time reading up on oo it really is a change of mindset!
There are still big holes though ;-)

I want to use the data in app, ultimately to display performance data as graphs etc.

Cheers Geoff
 

ArakelTheDragon

Joined Nov 18, 2016
1,362
It will take a real OOP programmer here. I think you should start with something in the middle like "C" in order to fill the wholes and than move on to "C++" and OOP.
 

John P

Joined Oct 14, 2008
2,026
This looks more like the kind of data that's usually presented on a spreadsheet. Do you really need to write your own programs instead?
 

Thread Starter

geoffers

Joined Oct 25, 2010
487
Thanks,
Tried c++ from scratch a few years ago, maybe not a good book but didn't get on very well.
I need a application to learn anything tho!
Java seems to be language of choice for android apps so I think I will go that way.
I maybe should have asked a sq lite question, its the best way to store list of data in a android app I'm thinking about?
Thanks Geoff
 

Thread Starter

geoffers

Joined Oct 25, 2010
487
Thanks,
Tried c++ from scratch a few years ago, maybe not a good book but didn't get on very well.
I need a application to learn anything tho!
Java seems to be language of choice for android apps so I think I will go that way.
I maybe should have asked a sq lite question, its the best way to store list of data in a android app I'm thinking about?
Thanks Geoff
 

joeyd999

Joined Jun 6, 2011
5,283
Are you trying to write a mobile app?

On a PC, my preference for custom database applications is to use a LAMP stack: Linux, Apache, MySql, and PHP. Yes, there is a lot to learn but at least setting up the system is relatively straight forward (Google "LAMP installation") and there are tons of tutorials online.

As a side benefit, the web interface can be accessed remotely, and all the data is stored on a master server.

There are even packages available that will allow you to report/process/analyze/graph your data online relatively easily.

There's a learning curve, but once you get the hang of it it's quite easy. I've written a number of these kinds of apps, mostly to run various aspects of my business.
 

MrSoftware

Joined Oct 29, 2013
2,197
If you're writing an app for Android, Java is the native language to use (Android Studio), or another popular option is Xamarin which uses C# and makes it somewhat easier to re-use your code across multiple platforms (Android, iOS, etc..). If you're relatively sure that Android is the only platform that you're interested in using, then java/Android studio may be the simplest way to go.

If you're storing a lot of data and want to query it, SQLite is helpful and very commonly used on Android. If you just want to log data and process it elsewhere, then you can just dump it to a log file in a formatted way that you can parse later.

If you want your data to be easily accessible online, then look into a service like Caspio, which provides SQL-like database services online. You can either store your data locally on your android device, then occasionally send it up to the Caspio database in the cloud, OR you can just send it directly to Caspio and not even bother with a local database on your Android device. Just be aware that this approach means that your app won't be very functional without an active internet connection.

Many ways to skin the cat, make a list of your requirements then use that to guide your choices on how to do it.
 

Thread Starter

geoffers

Joined Oct 25, 2010
487
Thanks everyone,
Lot to go on there, I was going with android as that seemed the most user/developer friendly? I may be wrong!

Bit more background, over the past few years I've made some RFID based feeders and RFID readers to gather data on my animals, a friend has asked me if I can make a weighing system for his cattle so I will do one for myself.

It seems the easiest way to collect all this data will be to use Bluetooth and a phone as we go about seeing stock etc.

I've spent more time than I want count on the rn4678 module but has it working quite well now so the Bluetooth side of things is quite straight forward.

I just want it to be easy to collect,store and interprate the data, I'm maybe to lazy to enter it into a spreadsheet every day but if the phone collects it all and saves it as I go I will use it!

So data I might want to store would be;
DOB
Farther
Mother
Service dates (if female!)
List of weights and dates (growth)
List of dates and feed consumed
List of dates and milk production

You get the idea, some bits won't change but others will be added to each day!

The database work I have done has just been to save a Unicode string which works for some entries but I assume would soon get unmanageable for others?

Cheers Geoff
 

joeyd999

Joined Jun 6, 2011
5,283
So data I might want to store would be;
DOB
Farther
Mother
Service dates (if female!)
List of weights and dates (growth)
List of dates and feed consumed
List of dates and milk production
It's obvious to me you should have multiple linked tables.

Each animal would have a master record with DOB and any other characteristics important to that animal in the main table.
A separate table could contain the IDs of the Father and Mother, either linked by fields in the animals record, or by using a pivot table.
Each of the lists would have their own table -- with columns for the animial ID and other information for that line item.
 

Thread Starter

geoffers

Joined Oct 25, 2010
487
Thanks Joey,
I will have to do a bit if googling but think I get the jist of it, haven't explored half what you can do with a database :)

Will probably have more questions soon!

Cheers geoff

PS. Your posts on various other threads have completely changed how I program pic's. Made my head hurt for a bit but life is much easier now !
 

MrSoftware

Joined Oct 29, 2013
2,197
Do a little reading on relational databases. Their whole purpose in the world is to store data in a way that is easy (relatively) to work with. Then if you decide to go the database route, before you start coding sit down and draw out all of your tables on paper. You might have several sheets of paper, tape them together to make a big chart. Spending the design time up front will save you a lot of work and frustration down the road. And actually, once you have the complete list of the data fields that you want to save, post it here and I'll bet someone will help you come up with the tables. As with everything, there will be multiple paths to a solution, but some planning and thought up front will help you choose a good one. :)
 

ArakelTheDragon

Joined Nov 18, 2016
1,362
Thanks,
Tried c++ from scratch a few years ago, maybe not a good book but didn't get on very well.
I need a application to learn anything tho!
Java seems to be language of choice for android apps so I think I will go that way.
I maybe should have asked a sq lite question, its the best way to store list of data in a android app I'm thinking about?
Thanks Geoff
The core android applications are written in "C". The user ones in "Java".
 

Thread Starter

geoffers

Joined Oct 25, 2010
487
Hi all,
Thanks for all the input, I've been thinking about it and I'm going to need to store 3 different 'types' of data ;

Data that won't change; dob, mother, farther, Id , name.

Data that will be added too occasionally; vet and meds mainly (hopefully not too often!), breeding data such as service date etc

Data that will be updated daily;
Milk yield, feed consumed, weight etc.

The milk yield is the one that will get the most entries, we have cows that have done 10 lactations, if they were recorded daily there would be around 3000 entries (I realise my cows are better than my android device! ;-) )

Will a database be happy with that many entries or would it be better to store the name of a text file holding the data.

I still think in bytes. It seems a lot.
Cheers Geoff
 

joeyd999

Joined Jun 6, 2011
5,283
Will a database be happy with that many entries or would it be better to store the name of a text file holding the data.
That many? You jest. 3,000 entries a large database does not make.

Why store the name to a text file? Your data will not be easily searchable.

Once the decision is made to use a database, use the database!
 

wayneh

Joined Sep 9, 2010
17,498
That many? You jest. 3,000 entries a large database does not make.

Why store the name to a text file? Your data will not be easily searchable.

Once the decision is made to use a database, use the database!
I wholeheartedly second this advice. You don't want to be messing with a text file. The exception would be for a small and quick project, because it's usually very easy to find examples of how to read and write to a text file. But if you take a bit more time to find examples of adding and managing database records, you'll be far better off in the long run. Let the database code do the heavy lifting. You just need to make your data compatible with it and learn to use the features.

If your target is Android, I believe your only practical development choice is Java.
 
Top