Lovro Bajc

Ranch Hand
+ Follow
since Jun 28, 2014
Merit badge: grant badges
For More
Cows and Likes
Cows
Total received
0
In last 30 days
0
Total given
0
Likes
Total received
0
Received in last 30 days
0
Total given
1
Given in last 30 days
0
Forums and Threads
Scavenger Hunt
expand Ranch Hand Scavenger Hunt
expand Greenhorn Scavenger Hunt

Recent posts by Lovro Bajc

Hi,

finally have come to solution. Minor changes and it works fine. I believe also that there can be other ways to do it in order to be more efficient.

here are the modifications:

happinessDb class modifications:



and in Chart class:

9 years ago
Hi

I have sort of the same problem. I need to obtain the data in Chart Activity from the database class and use it to populate chart. Since it is dynamic chart I created an ArrayList of Integers, however how to populate it with integers from database class I have no idea.

so far I have come up with a method in Chart calss:





Class getHappyData in the database should return the integers ArrayList HappyList. And here I have an issue how to obtain the integers and put them into HappyList in Chart.class.




any advice would be much appreciated.

thank you for your time.
9 years ago
Hi,

I am trying to obtain the ArrayList of Integers from database to be used with the activity containing the Chart (mChartEngine). When the Chart activity (OnCreate) is initiated the code looks for the method happyDataFromDb. It's main purpose should be to obtain the integers from the happinessDb (SQLite database) and store it in an array called happyList in Char activity.

after I try to run the activity i get an error leading to the addHappyData which is initiated for drawing the chart specifically in for loop.

help would be much appreciated!

brg

HappinesDB:




Chart Activity:

9 years ago
Hi everyone,

I am trying to create an onClick method where upon pressed state application would save data in csv to specific folder on public directory. After every click, the application would append the data to that single file which was created the first time. When I run the application, the folder is created and also is the "happy_log.csv, however when i further press the save button it does not add extra line with new data. So far my code looks like this:



assistance on this matter would be much appreciated.
9 years ago
Found the solution In the OnCreate the setContentView was missing.
9 years ago
Hi Everyone,

everything was working fine till yesterday, and that out of nowhere appeared following problem. Once the main activity is started there are two buttons which based on the selection initiate new activity. The onClick method checkStats works normally, however method startHappinessMeter (uppon click) results in "Unfortunately, Happy App has stopped":

Main Activity code:





Error which is returned when I press the button:





I checked the line 26 in below provided java file and I cant understand why it guides me to the greatBtn onClick listener?




Help would me much appreciated!

best regards
9 years ago

Ulf Dittmer wrote:So now everything works ?



Yep work perfectly, thanks a lot. Just one more question still regarding the previous post you made:

Ulf Dittmer wrote:What is the point of storing data as file (no matter the format) if the same app reads it later? Why not keep it in memory?



Obviously there would be a lot of practices and variables stored after certain period of time. Would you still keep it in memory or would you go for something else? I am quite new on this side as you have probably noticed, so any suggestion is most helpful to open my horizons .

thank you again

brg
9 years ago

Ulf Dittmer wrote:You misunderstood. What are the *actual* values? Not what you think they are, but what they actually are. Print them out and make sure they match your assumptions.



Thanks for assisting me with the basic print idea . Since array values were exactly what it was stored in the csv,I took a look at the following part from bottom up and correct it:





9 years ago

Ulf Dittmer wrote:In that case, an answer to this would be helpful:

Ulf Dittmer wrote:What are the values of the elements of the "a" array for the line that's giving you trouble?



The values are integers, which need to be than used for data projection on graph. Is than array a problem or the Dataset?
9 years ago

Ulf Dittmer wrote:

the problem is that no matter what I try, I cant access the 4th element and use it to draw an extra line to the chart.

normalList.add(Integer.parseInt(a[3]));


The code you posted seems to do just that, so what exactly happens when you you run? TellTheDetails



There is no error, just application does not show the second line on a graph (Data for "mDataNormal") at all, so I was thinking that there is something wrong with obtaining the array.
9 years ago

Ulf Dittmer wrote:What do you mean by "call out"? What exactly is the problem? The code shows how to access the 3rd element - what prevents you from similarly accessing the other elements?



the problem is that no matter what I try, I cant access the 4th element and use it to draw an extra line to the chart.


9 years ago

Ulf Dittmer wrote:

but if there is 5 practices per week for a 6 month period, wouldn't it be better to have it stored in file somewhere?


We don't know what that data is intended for, that's why I asked. My question was not about long-term storage, it is about the fact that the app writes to a file and then reads form the same file - that seems inefficient to me. Why convert Java objects to a file representation only to convert that back to Java objects within the same app? (Especially if it gives you problems, I might add :-)

At a quick glance, the CSV looks OK. What are the values of the elements of the "a" array for the line that's giving you trouble?



the problem is that I cant find the way how to call out the 4th column and the 5th to obtain variables with the splitting the string lines. and than use those values as reference numbers for a second data line in the chart.





9 years ago

Ulf Dittmer wrote:Have you looked at the CSV to see if it's properly formatted? Post it here.

What is the point of storing data as file (no matter the format) if the same app reads it later? Why not keep it in memory?



but if there is 5 practices per week for a 6 month period, wouldn't it be better to have it stored in file somewhere?

Unfortunately I cant save the actual file so hope copy of the text will do....


Aug-30-2014,08:06 AM,0,0,0
Sep-05-2014,08:09 AM,0,3,2
Sep-05-2014,08:10 AM,0,3,2

9 years ago
Hi everyone. Firs end foremost a short purpose of application I am trying to create.

Main goal is to provide monitoring widget for my coaches. To be able to do that a certain data needs to be stored. I used for data storing the csv file. The 4 columns are Date, Time,No. of Happy,No of Normal,No of Sad.
Since I want to make a visual graphical interpretation of the results I need to call the data back from the csv.

With the help of different tutorials I was able to get the data out for third column (No of Happy) however, cant find the way how to call than the 4th and 5th column, and also the Date.

The reason behind is, that I would like to plot a chart based on the 3 columns with aChartEngine.

can you please assist me on this matter?

Saving the stats to csv



Reading the stats from csv for usage in chart



Thank you for your help
9 years ago
Thanks for all the help. With it I cleared up a bit mess in my head . Thanks a lot
9 years ago