-1

I am building my first Android app. I want to collect opt-in data from the user (let's say input data), save it and ultimately view it as a CSV.

I attempted to use the Google Sheets API, but reached a dead end. I'm wondering if there are alternative ways to store data.

The data will be fairly large (the data will be collected every few minutes for several hours) So I don't want to take up too much storage space on the user's phone. I'd love to upload the data to some sort of cloud, but am lost outside of Google Spreadsheet API

auto
  • 1,062
  • 2
  • 17
  • 41

1 Answers1

1

A very common solution is to create a Database. SQLite offers a lightweight and snappy experience in Android. Data will be stored persistently until app uninstallation, app data cleared in settings or altered by the user in-app (if you wish to implement such function).

Saving Data in SQL Databases

Later on you could export the data from the database by creating a CSV file. The solution to this last bit was already answered here.

The data will be fairly large (the data will be collected every few minutes for several hours) So I don't want to take up too much storage space on the user's phone.

If data will require X amount of space, X will be the minimum required to store it. The best thing you can do is to use a system that does add too much overhead (again, SQLite is very good at this if you tailor well your tables in the database).

Community
  • 1
  • 1
Matei Radu
  • 2,038
  • 3
  • 28
  • 45
  • So will I be able to save a ton of data without impacting the user's phone or data plan (sorry if that's a stupid question)? And how would I later retrieve that data. I don't really have an idea of exactly how much data (in terms of size) I will need – auto May 02 '16 at 23:20
  • @auto as long as you don't have to deal with media files such as audio recording, images and videos, alphanumerical values use very few data, both on phone memory or data plan. An SQLite db per se doesn't require an internet connection as it is a local implementation in the Android system, so in your scenario the data plan would be affected only if the user uploads somewhere the CSV file (and, again, we are talking or relatively low data usage) – Matei Radu May 02 '16 at 23:27
  • @auto in the case of alphanumerical values we are talking about bytes and kilobytes, so to use something like 100MB of space you would need more than 1 milion records. Of course this example is just to give you an idea of the amount of space involved in your scenario. Depending on how many values you want to store and on the interval your mileage may vary. – Matei Radu May 02 '16 at 23:37
  • Thanks. This is extremely helpful! I think this is the route I should go. I will look into retreiving the data – auto May 02 '16 at 23:40
  • @auto you're welcome. [This](http://mobilesiri.com/android-sqlite-database-tutorial-using-android-studio/) tutorial seems fairly complete and up-to-date, take a look. If this answer has sufficient for your question, remember to mark it as accepted, so others can benefit from it. – Matei Radu May 02 '16 at 23:44
  • I think I may have the database working, but I have no way of checking it. Once the app is downloaded, how do I access the database so that I can use the data as a csv? Currently the database does not show up at all in the file.. – auto May 03 '16 at 10:22
  • Let us [continue this discussion in chat](http://chat.stackoverflow.com/rooms/110899/discussion-between-matei-radu-and-auto). – Matei Radu May 03 '16 at 11:08