0

I'm learning android by doing my sample app. Service within app periodically saves phone's location to database. Default frequency depends on GPS provider, which sends new coordinates, when position is changed. So, if I'm travelling by car amount of locations during long trip could be vast. Problem that I'm facing now - what mechanism should I choose to write and read this data to db? The easiest one is ORM (ORMLite). And I think there would no problems to write to DB. What worries me - is reading data. Surfing stackoverfow, I've found problems connected with reading big amounts of data (thousands of rows) by means of ORMLite, which lead to up to few minutes delays. As for now I plan to load this location to build route and show it on map, for example. So, should I replace my ORMLite approach with something else and what would be this "something else"? Or it is possible to use ORM to write and something else to read data? Though I'd like to use some uniform approach to talk to DB within my app.

Thanks in advance!

Andrey Khataev
  • 1,303
  • 6
  • 20
  • 46
  • You need to be more specific about what kind of problem you are facing. Saying that something "could be slow" without actually trying it and without any kind of data to measure said slowness doesn't really give us anything to work with. There are lot's of possible reasons something could be slow--the number of rows of data is only one of those things. – Karakuri Dec 01 '14 at 15:39
  • What am I going to do is similar to this question http://stackoverflow.com/questions/7811466/ormlite-dao-in-android-getting-really-slow-when-querying-more-than-few-thousand and since there is no definite answer in that thread, I'm asking some advice here. I think I'll try to end up with ORMLite and see the real numbers. Just wanted to know if I'm going right way beforehead or should I use another approach – Andrey Khataev Dec 01 '14 at 16:34

1 Answers1

0

We have been using an ORM solution for years that can handle thousands of items in a results set and it is incredibly fast. We typically use the ORM tool to create a Cursor for the results, then do the following to pull the data from the Cursor:

Individual individual = new Individual(cursor);
name = individual.getName();
age = individual.getAge();
... etc ...

or

String name = Individual.getName(cursor);
int age = Individual.getAge(cursor);

The tool that we use (I'm an author) is DBTools (https://github.com/jeffdcamp/dbtools-android).

Jeff Campbell
  • 1,565
  • 2
  • 15
  • 18