1

I can appreciate why Java has so many different data classes. In the longrun, having all these special classes must allow for extremely powerful apps with little code. That's great and all, however, learning all of these data classes is a total mindscrew coming from other platforms!

This being said, I am trying to wrap my head around ResultSet and Cursors. I am trying to utilize opencsv3 to dump my database into a .csv file, however, opencsv requires I use a ResultSet and not a Cursor to do so. I’ve looked everywhere for an explanation as to how I can pull a ResultSet from my sqlite database, it appears it’s not supported by Android?

If ResultSet is not supported, is there a simple way to convert my Cursor to a ResultSet? At this point, I am thinking I will just read the database using a Cursor and write my own damn .csv Class instead of using opencsv. Any suggestions would be very much appreciated, I guarantee you I will reply and accept your answer if applicable!

Thank you!

CommonsWare
  • 986,068
  • 189
  • 2,389
  • 2,491
AutoM8R
  • 3,020
  • 3
  • 32
  • 52

1 Answers1

3

I’ve looked everywhere for an explanation as to how I can pull a ResultSet from my sqlite database, it appears it’s not supported by Android?

In theory, you can use the JDBC stuff with SQLite. SQLDroid appears to be one JDBC driver you could use, and there may be an undocumented/unsupported SQLite driver in Android proper.

This, however, is not the normal approach for SQLite access in Android.

If ResultSet is not supported, is there a simple way to convert my Cursor to a ResultSet?

ResultSet is an interface. You are welcome to attempt to create a CursorResultSet implementation that wraps a Cursor. ResultSet is a massive interface, though, so this approach will be tedious at best.

At this point, I am thinking I will just read the database using a Cursor and write my own damn .csv Class instead of using opencsv.

You do not need a ResultSet to use opencsv, as the documentation illustrates. Or, there are plenty of other CSV implementations for Java.

Community
  • 1
  • 1
CommonsWare
  • 986,068
  • 189
  • 2,389
  • 2,491
  • Thanks CommonsWare, I bought your books for 2.2, still making my way through them, great value, thanks! I have been struggling to understand Java, but I hope after this first app I will have the basics of Android development. I was pretty amazed at how you published your books so soon, over a year later, I'm still trying to grasp many concepts! People don't hear this enough: you inspire me to learn Android, thanks! – AutoM8R Mar 08 '12 at 15:58