As long as you are avoiding object allocations, it seems reasonable.  The
fact that your subject says "Object[]" indicates you might create an object
for each row, which (depending on the expected number of results), you
should generally avoid.

On Tue, May 12, 2009 at 3:17 PM, Hamilton Turner <
[email protected]> wrote:

> So I have a database with 2 tables. One is the Polygon table, and each row
> in Polygon can map to multiple rows in the Points table. I want a
> fetchAllPolygons function, similar to the sample Notepad application. I
> could do something like this (I could make it better, but that's the main
> point):
>     /**
>      * Return a Cursor over the list of all notes in the database
>      *
>      * @return Cursor over all notes
>      */
>     public Cursor fetchAllPolys() {
>
>         return mDb.query(DATABASE_TABLE, new String[] {KEY_ROWID,
> KEY_TITLE
>                }, null, null, null, null, null);
>     }
>
>     public Cursor fetchAllPolyPoints() {
>
>         return mDb.query(DATABASE_TABLE, new String[] {KEY_ROWID, KEY_X,
>                 KEY_Y}, null, null, null, null, null);
>     }
>
> but that is 1) a pain, and 2) I don't want the rest of my application to
> have to understand the database layout. I don't know of a CursorAdapter that
> will do the transforms I am looking for, so I will write them myself.
>
> So, the question - I am thinking of simply subclassing the Polygon, to
> create a DatabasePolygon, with all of the calls simply being the correct
> callthru's to the Cursor. I am thinking that this will still preserve the
> usefulness of Cursors, will use very low memory because they are wrapper
> classes, and will allow the rest of my application to never know anything
> about the database, simply about Polygon.
>
> Thoughts?
>
> Thanks,
> Hamilton
>
> >
>


-- 
Dianne Hackborn
Android framework engineer
[email protected]

Note: please don't send private questions to me, as I don't have time to
provide private support, and so won't reply to such e-mails.  All such
questions should be posted on public forums, where I and others can see and
answer them.

--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google
Groups "Android Developers" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to