Problem with Preference - OutOfMemory Error

by Vanraj » Wed, 29 Jul 2009 10:50:57 GMT

Sponsored Links
 Hello All,

I am getting some strange problem.

I am having one

class ABC extends PreferenceCategory .. and this ABC class is added in
preference xml and drawing the UI from that XML.

Now based on events i am adding and removing the children Preference from
the PreferenceCategory(ABC).


ABC abc = new ABC(); // this is PreferenceCategory

// based on events
Preference myPref = new Preference();

this all works fine. But when i added my class which is extending the
Preference .


public* *class* MyClass *extends* Preference{

*public* MyClass(Context context) {

*             super*(context);



and code is same just object changed
*Preference myPref = new MyClass();*
*// based on events*

And i will get *out of memory error* after some time.  This sound stupid but
it is true. Now *in case of MyClass if i use CheckBoxPreference* *as it is
extending Preference i am not getting error and there is no VM Heap size
grow while running the apps*. So what is wrong with *MyClass . i am not
doing any special things in that.*

/ Vanraj


Other Threads

1. Problem reading datebase via content provider


I created SQLite base with 3 tables and custom ContentProvider.  I had
a crash on first call method query.
I tried to get cursor from base via db.query(table, columns,...) it
worked correctly.

The exception is android.database.sqlite.SQLiteException: no such
column: modified: , while compiling: SELECT items._id, FROM
items ORDER BY modified ASC

Whats wrong?

The method is below:

        public Cursor query(Uri url, String[] projection, String selection,
                        String[] selectionArgs, String sort) {
                SQLiteQueryBuilder qb = new SQLiteQueryBuilder();
                String tableName = getTableName(url);
                final int uri = urlMatcher.match(url);
                String defaultOrderBy = null;

                if (isCollectionUri(url)) {
                        switch (uri) {
                        case ITEMS_URI_CODE:
                                defaultOrderBy = Items.DEFAULT_SORT_ORDER;
                        case LISTS_URI_CODE:
                                defaultOrderBy = Lists.DEFAULT_SORT_ORDER;
                        case CELLS_URI_CODE:
                                defaultOrderBy = Cells.DEFAULT_SORT_ORDER;
                                throw new IllegalArgumentException("Unknown URL 
" + url);


                else {
                        qb.appendWhere("_id=" + url.getPathSegments().get(1));

                String orderBy;

                if (TextUtils.isEmpty(sort)) {
                        orderBy = defaultOrderBy;
                } else {
                        orderBy = sort;
                // this method throw sqliteexception: no such column: 
                Cursor c = qb.query(db, projection, selection, selectionArgs, 
                                null, orderBy);

                c.setNotificationUri(getContext().getContentResolver(), url);
                return c;

The Log is 08-13 11:49:59.471: ERROR/AndroidRuntime(5237): Caused by:
android.database.sqlite.SQLiteException: no such column: modified: ,
while compiling: SELECT items._id, FROM items ORDER BY
modified ASC


2. Dalvik VM vs Sun JVM - compabillity

Hi all
I am new to Android development

Are there any compability issues between a standard JVM and Dalvik VM?

Are there any classes or packages from the Sun SDK that can't be used on

Best regards
Per-Jarle Sther


3. Exception on Pending Intent

4. What will happen to existing connections when switch between 3g/wifi

5. SQLiteException

6. Does Google provide direct (paid) technical support for Android SW development?

7. Alarm Clock with specific ringtones