简体   繁体   中英

What's the best way to store events in a database on android?

I've been struggling with this problem so here is my first SO post.

I'm writing an Android app that needs to store events with seconds precision. After this data gets collected for a while, I'd like to be able to display it in a graph where the user can view this event history over time. This makes me think of using a sqlite database in android with a table with columns:

| eventname | timestamp |

Then I can get the number of each event type by counting rows in the table, and show the graph based on Last Day, Last Week, Last Month, etc. I've never worked with databases before though, so I'm not sure if this is a good approach to what I assume is a common problem.

Any help is appreciated!

For me the main criteria if to use database or no, it would be: - persistance - if you want to keep the data for long period and to return to them ex. after a week or a month - how complicated the structure is (for simplier, perhaps just an xml file would be easier, or txt file etc.)?

You don't write too much so it's difficult to advise. I believe you will have to read a lot if you have never worked with databases earlier.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM