0

I've been playing around with android sqlite and I noticed it uses a cursor. Is their a function that takes query as input and returns a 2D array for all results.

I come from php and its a lot more easy, but i can't find any similar function any where!

2
  • You really don't want to put the results of a (possibly very large) database query into an array on a device as memory-constrained as a smartphone. What do you want to do with the data? There most likely is a better approach. Commented Sep 8, 2011 at 17:03
  • i will be reading back and forth many times as i traverse each and every single row. it is an optimization type. and no the fetch result is very small. possibly 10 rows or at most 100 Commented Sep 8, 2011 at 18:39

1 Answer 1

1

No, the Cursor is what is used for all database query results. The Cursor object is beneficial to Java because it is a strongly-typed language. PHP uses dynamic weak typing which lends itself to that kind of SQL query response. Also there are memory considerations that a Cursor will solve by being able to see only one row of data at a time.

Sign up to request clarification or add additional context in comments.

2 Comments

perhaps ur right, but sometimes i need to fetch whole query into an array and then traverse certain rows, depending on the algorithm
You can pull all the data you want, the point is that the Cursor helps you manage it.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.