Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Suggestions on how to Save Data

I am just starting in Android programming. I have an App that gives progoses based on mathematical methods of stock papers and warns when a stock paper is going to rise or fall. I have a Depot Class that contains a list of papers that are being watched. My Question now is what is the best and hopefully easiest way to store the data.

As I said my depot has an ArrayList of my Stock Paper Class. The User can add and remove to this. My paper Class has the following Values which should all be saved:

protected String Bezeichnung;
protected String WKN;
protected String ISIN;
protected String Typ;
protected String Schwerpunkt;
protected String Domizil;
protected String KAG;
protected Date Stand;
protected List<History_Entry> Historie;
protected Date Startdatum;
protected Date Enddatum;
protected int Durchschnitt1 = 200;
protected int Durchschnitt2 = 38;

The Tricky thing is the Historie Value. It contains all the historical Values of the StockPaper. It is an ArrayList with the Class History_Entry. History_Entry basicly just has a double Value with the Value and the corresponding date. Further it has the two Average Values but i can recalculate those at the beginning.

My Idea is to establish a Database that contains all the historical Values. And a Database that contains the Stock Paper Name and all the other Values from the Paper class.

I hope I am not to far off, but i am happy about anything new to learn.

like image 209
Carsten Berensmeier Avatar asked Oct 20 '22 12:10

Carsten Berensmeier


1 Answers

Solution for you depends how big your data is and what you do with it.

Is it big? Do you search a lot by keys? Do you do aggregation, filtering, selection? If one of answers is "yes" then you need database approach.

If "No" then you can use any simple approach. I see all your data is String or convertible to String. You may simply save file with rows as your records and later read it and parse with split function. That's few lines of code.

Another approach is serialization All your data - String, double and ArrayList are serializable. Simply serialize/deserialize to local file. There a lot of examples or tutorials how to do simple serialization.

like image 182
Alex Avatar answered Nov 04 '22 00:11

Alex