Re: [android-developers] Re: Alternatives to SQLite for static data

2011-06-10 Thread Daniel Drozdzewski
On Thu, Jun 9, 2011 at 9:50 PM, nadam a...@anyro.se wrote:
 Thanks. It's no saving and no search. Just query and display. The
 items will be displayed as a ListView and the user can chose two
 different ways to sort the list and filter the list based on specific
 predefined values.

 To be more specific, it's a list of around 60 places that can be
 sorted by name alphabetically or sorted based on the distance from
 where you are (so some dynamic data too, but no need to save that).
 The filtering can be for instance to only show the places that belong
 to a specific category.

SQLite seems like an overkill.

1) Read it at start to a List that will back your ListAdapter.
2) Use java.util.Collections.sort() to sort your list passing one of 2
different Comparator objects depending on what user has chosen.


Daniel

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


[android-developers] Re: Alternatives to SQLite for static data

2011-06-09 Thread Streets Of Boston
If it is simple sorting, write your own custom adapter (BaseAdapter, for 
example).

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

[android-developers] Re: Alternatives to SQLite for static data

2011-06-09 Thread DanH
Not clear:  Do you want to simply be able to query the data different
ways, or do you want to be able to rearrange the order of the data and
save that?

If you know all the different ways that the data might be queried,
it's a simple matter to build static side tables for them.  If you
want to be able to search for individual values you can statically
or dynamically create a hashtable (or several) over the data.

Of course, none of this really works well with JSON or XML -- you
really need a flat file.  For XML or JSON you're probably better off
reading in all the data and building hashtables over it.

On Jun 9, 11:35 am, nadam a...@anyro.se wrote:
 Say you're reading an xml or json file from within your app (resources/
 raw or assets) and then want to show this data to the user and enable
 sorting and simple filtering. Of course you can save the data to an
 SQLite table and use sql (where and order by), but it seems to be
 overkill when dealing with ~30 kB of static data.

 Would it be more appropriate to write a custom adapter or are there
 other alternatives that you would recommend?

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


[android-developers] Re: Alternatives to SQLite for static data

2011-06-09 Thread nadam
Thanks. It's no saving and no search. Just query and display. The
items will be displayed as a ListView and the user can chose two
different ways to sort the list and filter the list based on specific
predefined values.

To be more specific, it's a list of around 60 places that can be
sorted by name alphabetically or sorted based on the distance from
where you are (so some dynamic data too, but no need to save that).
The filtering can be for instance to only show the places that belong
to a specific category.

On 9 Juni, 21:56, DanH danhi...@ieee.org wrote:
 Not clear:  Do you want to simply be able to query the data different
 ways, or do you want to be able to rearrange the order of the data and
 save that?

 If you know all the different ways that the data might be queried,
 it's a simple matter to build static side tables for them.  If you
 want to be able to search for individual values you can statically
 or dynamically create a hashtable (or several) over the data.

 Of course, none of this really works well with JSON or XML -- you
 really need a flat file.  For XML or JSON you're probably better off
 reading in all the data and building hashtables over it.

 On Jun 9, 11:35 am, nadam a...@anyro.se wrote:







  Say you're reading an xml or json file from within your app (resources/
  raw or assets) and then want to show this data to the user and enable
  sorting and simple filtering. Of course you can save the data to an
  SQLite table and use sql (where and order by), but it seems to be
  overkill when dealing with ~30 kB of static data.

  Would it be more appropriate to write a custom adapter or are there
  other alternatives that you would recommend?

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