Cursor.getString() truncating Strings issue

by Damien Cooke » Mon, 27 Dec 2010 22:36:49 GMT


Sponsored Links
 Hi All,
I have an app that stores it's local data in a database,  The database has a 
TEXT field called description that on some rows is truncated on retrieval. I 
have checked the database by running it app in the emulator and grabbing the 
database and checking the contents.  So I know the data is there.  I retrieve 
it using:


public Cursor getAdditiveByRowID(long rowId) throws SQLException 
    {
        Cursor mCursor =
                db.query(true, Additives.DATABASE_TABLE, new String[] {
                                Additives.KEY_ROWID, 
                                Additives.KEY_IDENTIFIER,
                                Additives.KEY_NAME,
                                Additives.KEY_TYPE,
                                Additives.KEY_DESCRIPTION,
                                Additives.KEY_ACKNOWLEDGEMENT,
                                Additives.KEY_WARNING
                                }, 
                                Additives.KEY_ROWID + "=" + rowId, 
                                null,
                                null, 
                                null, 
                                null, 
                                null);
        if (mCursor != null) {
            mCursor.moveToFirst();
        }
        
        return mCursor;
    }



When I use it the code looks like this:

if (cursor.moveToPosition(position))
                {               
                        
                        Log.i(TAG,"contents from cursor = 
"+cursor.getString(Additives.DESCRIPTION_COLUMN));
                        
                        ......
                        
record.setDescription(cursor.getString(Additives.DESCRIPTION_COLUMN));
                        ......
                }

I checked the output and it appears to be truncating the output at various 
stages (one it is 1980 chars before truncating and another it is 257 chars) 
with some rows only.  I checked for bad chars but as I thought it was fine (the 
same database is used in my iPhone app with no problems) So it must be 
something I am doing.  But I can not see where as it is wrong as soon as it 
comes from the database.  Any assistance or advice to debug this would be more 
than helpful.

Regards
Damien




-- 



Re: Cursor.getString() truncating Strings issue

by Frank Weiss » Mon, 27 Dec 2010 23:54:08 GMT


 logcat may be truncating, have you also tried

 Log.i(TAG,"contents from cursor =
"+cursor.getString(Additives.DESCRIPTION_COLUMN).length());

-- 


Sponsored Links


Other Threads

1. Statistics Frozen...Again

My Active Installs/Total Downloads hasn't updated in nearly a week -- Is
this just me?

-- 
Sincerely,
Brandon N

-- 
.

2. mHeatlh mobile health platform developers Boot Camp

Hi All,

What would you build if you had access to a user's nutrition, sleep,
and weight history? What if you had access to their medical history?

AT&T is building a mobile health and wellness data ecosystem and
invites you to participate in this alpha release of the mHealth
platform. Get on board with AT&T now to develop the first applications
onto of the mHealth platform using the most popular health and
wellness devices on the market today. Shape the direction of the
platform and collaborate to build an ecosystem. The best applications
from the bootcamp will win prizes and be shown to AT&T executives at
the next Innovation Summit in June.

The two day boot camp will cover the ins and outs of the platform and
APIs, the mobile SDK, and will include the participation of ecosystem
partners like Sencha and Ericsson. Breakfast and lunch will be
provided.

Where: AT&T Foundry in Palo Alto, CA
When: May 9th + 10th, 2011

Space is limited, so please apply as soon as possible:
http://foundry.att.com/mhealth/devcamp/

-- 
.

3. help for oops concept in android?

4. Show Context Menu other than on long press?

5. Xperia arc and neo

6. Esky for free call & pc (pc&mobile)

7. sent a text message encrypted