When I am executing a SQLite query (using sqlite4java) I am following the general scheme of executing it step by step and obtaining one row at a time. My final result should be a 2-D array, whose length should correspond to the amount of records. The problem I am facing is the fact that I don’t know in advance how many records are to be returned by my query. so I basically store them in an ArrayList and then copy pointers to the actual array. Is there a technique to somehow obtain the number of records to be returned by the query prior to executing it fully?
When I am executing a SQLite query (using sqlite4java) I am following the general
Share
Why? It would generally be a better idea to make the result a
List<E>whereEis some custom type representing “a record”.It sounds like you’re already creating an
ArrayList– so why do you need an actual array? The Collections API is generally more flexible and convenient than using arrays directly.