Filling a large database causes crash

by NFSpeedypur » Tue, 10 Mar 2009 11:00:25 GMT


Sponsored Links
 I am trying to on first start up fill up a sql database with the
default values.  This database is around 9000 entries and it is
causing the app to go over the 16MB heap.  I am trying to find a way
to do this so that it will not cause this over flow.

At the moment I am running the 9000 inserts, 1 after another in a
thread.  Are there any other suggestions?



--~--~---------~--~----~------------~-------~--~----~



Filling a large database causes crash

by Mark Murphy » Tue, 10 Mar 2009 21:19:35 GMT


 


Use transactions. The heap problem is probably due to SQLite holding
everything in transaction buffers. You might, say, do a transaction for
every 100 entries or so.

-- 
Mark Murphy (a Commons Guy)
 http://commonsware.com 
_The Busy Coder's Guide to Android Development_ Version 2.0 Published!

--~--~---------~--~----~------------~-------~--~----~


Sponsored Links


Filling a large database causes crash

by NFSpeedypur » Thu, 12 Mar 2009 00:20:09 GMT


 I changed this to loading the database in from an asset and it works
fine.  But the issue is now the loading time.  On the emulator it
takes over 5 seconds for the list to be populated.  And when doing a a
filter (getListView().setTextFilterEnabled(true);) it takes almost 10
seconds to filter the list.  Is it unreasonable to think that about
9000 entries should be sorted faster?

Mark,

Does your book talk about handling this type of stuff?  I see that
version 2.0 is not in print so I plan to pick it up.

David





--~--~---------~--~----~------------~-------~--~----~



Filling a large database causes crash

by Mark Murphy » Thu, 12 Mar 2009 00:37:40 GMT


 


That feels wrong, but I haven't tried a 9,000-row table.


Did you add an index on the to-be-filtered columns?


There's some coverage of this in the _Advanced Android_ book (not yet in
print, beta available to subscribers), with more to come as that book
gets expanded over the course of the next 12-18 months.


Version 2.0 is available in print. If you're looking at the Amazon page,
they *still* have not updated the cover (grrrrrrrrr) -- I'll be trying
to do that again later this week.

-- 
Mark Murphy (a Commons Guy)
 http://commonsware.com 
_The Busy Coder's Guide to Android Development_ Version 2.0 Available!

--~--~---------~--~----~------------~-------~--~----~



Filling a large database causes crash

by NFSpeedypur » Thu, 12 Mar 2009 01:08:42 GMT


 No I did not add any index to the to be filtered columns, I am using a
basic array so I did not know there could be a index?

setListAdapter(new ArrayAdapter<String>(this,
                android.R.layout.simple_list_item_1, Titles));

Maybe it will be worth grabbing the subscription on Commonwares
instead of the book.  If I download the pdfs, am I able to print pages
for personal use or is it only for computer viewing?

David





--~--~---------~--~----~------------~-------~--~----~



Filling a large database causes crash

by Mark Murphy » Thu, 12 Mar 2009 01:13:09 GMT


 


If the data is in a database, use a CursorAdapter or
SimpleCursorAdapter, rather than loading them all into an ArrayAdapter.
That should be significantly faster.


Printing is perfectly fine for personal use.

-- 
Mark Murphy (a Commons Guy)
 http://commonsware.com 
_The Busy Coder's Guide to Android Development_ Version 2.0 Published!

--~--~---------~--~----~------------~-------~--~----~



Filling a large database causes crash

by NFSpeedypur » Thu, 12 Mar 2009 01:19:51 GMT


 I believe I understand more of what you are saying about adding the
index.  Do you mean to the actual column in the database?  Does
filtering the text requery the database each time?

David







--~--~---------~--~----~------------~-------~--~----~



Filling a large database causes crash

by NFSpeedypur » Thu, 12 Mar 2009 01:21:53 GMT


 I see yes I had tried the cursor in the past and it does work faster,
but I could not get the Filter to work.  Do I need to write my own
search portion if I use the cursor method?

Thank you for your help.  You personally have been a lifesaver to me,
in the android field.

David






--~--~---------~--~----~------------~-------~--~----~



Filling a large database causes crash

by Mark Murphy » Thu, 12 Mar 2009 01:22:02 GMT


 


That I don't know -- I haven't tried filtering. My guess is yes, but
queries, particularly on indexed columns, should be pretty snappy.

-- 
Mark Murphy (a Commons Guy)
 http://commonsware.com 
_The Busy Coder's Guide to Android Development_ Version 2.0 Published!

--~--~---------~--~----~------------~-------~--~----~



Filling a large database causes crash

by Mark Murphy » Thu, 12 Mar 2009 01:24:25 GMT


 


Unfortunately, I don't know -- I haven't tried filters with cursors as
yet. There's just *so* many nooks and crannies to play around in! I'll
add that to my to-do list for a future edition of _Advanced Android_.

-- 
Mark Murphy (a Commons Guy)
 http://commonsware.com 
_The Busy Coder's Guide to Android Development_ Version 2.0 Published!

--~--~---------~--~----~------------~-------~--~----~



Filling a large database causes crash

by NFSpeedypur » Thu, 12 Mar 2009 01:25:47 GMT


 Alright well I will work on that and maybe send you an email if I can
find additional information about it.  I just purchased a commonswares
subscription and I look forward to reading your books.

David





--~--~---------~--~----~------------~-------~--~----~



Filling a large database causes crash

by Will » Sat, 14 Mar 2009 08:41:48 GMT


 You will need to write your own filter when filtering.  I have only
done it with a Cursor (SimpleCursorAdapter sepcifically).  Searching
the Developer group for AutoCompleteTextView should send you in the
right direction.






--~--~---------~--~----~------------~-------~--~----~



Other Threads

1. I want to make some foreigner friends!

I want to make friends with some foreigher, I am a chinese, I want
discuss android with the foreign friends, there are two purpose, first
is the technology discuss, second, I want to practise {*filter*}English
with foreigners.
--~--~---------~--~----~------------~-------~--~----~

2. Multicast UDP recv problem

Hi,

I am running into a very strange issue-

When I recv() on a multicast UDP socket (using tiwlan0/wifi), i only
occasionally receive packets even though many should be seen.

I repro this with a very basic C application.

The only piece other piece of information is that when I do receive
packets, it's 'around' the time that I send them, as if sending
somehow causes a receive or two to get processed correctly for a short
period.

I feel like something is going on in the kernel networking layer, or
in the wifi driver.  Has anyone experienced anything like this and/or
has any advice for me?

Thanks,
-cliff
--~--~---------~--~----~------------~-------~--~----~
unsubscribe: android-kernel+unsubscr...@googlegroups.com
website: 

3. Who wants a 鈾?

4. ScrollView initialization - bug or stupidity?

5. Licensing/Protecting apps

6. SD Card ID

7. Concern about application file size for publishing due to Media files