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. Flyscreen in Market!!!

Barusan cek market eh ada flyscreen..



--- Sent with SEVEN on Android - the new generation of mobile messaging

--~--~---------~--~----~------------~-------~--~----~
Google Groups "Indonesian Android Community [id-android]" group.

To post to this group, send email to id-android@googlegroups.com

To request to subscribe to this group, please visit the following page:
 

2. Listen from google labs

When I do adb logcat I see debug messages from Google Labs Listen app
I thought they recommend we remove debug logs for release.
They also print my email in log, which might be security problem?
--~--~---------~--~----~------------~-------~--~----~

3. sending an SMS and an e-mail.

4. Newbie question - firmware version

5. Porting Java app to Android--the basics

6. DDMS doesn't show process list on device

7. can I get XML information step by step using SaxParser??