Hi,

I run into a bunch of errors when running my app and calling these methods
from multiple threads.

Namely;

SqlLiteMisuseException (Library called out of sequence)

SqlLiteException (unknown)  Error while compiling statement

IllegalStateException trying to use a closed reference

I understand this is poor coding on my part but I'm in deep now and i was
wondering if anyone had some reference code for good database use. It has to
be from a helper class available to multiple threads and not be an activity
in itself. I'm doing more than just display items in a list and all I can
find is examples of code that use a database for that purpose.

// Called from multiple threads
public Filter getFilter(int _id) {
        // A sub call to another db query method
        Filter filter = getBasicFilterDetails(_id);

        Cursor c = getFilterNodes(_id);

        c.moveToFirst();

        Map<Integer, Expression<Bitmap>> filterNodes = new HashMap<Integer,
Expression<Bitmap>>();

        while (!c.isAfterLast()) {
            // Mapping to an object from DB rows

            c.moveToNext();
        }
        c.close();
        c = null;
        // Return the output node
        filter.setNodes(filterNodes);
        return filter;
    }

etc.

Should I just synchronize these methods?

Any thoughts appreciated.

Kind regards,

Gavin

--~--~---------~--~----~------------~-------~--~----~
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
-~----------~----~----~----~------~----~------~--~---

Reply via email to