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. XDA Members Need Your Help

Hello everyone,
Recently a select few of us using the T-Mobile G1 and HTC ADP devices
have had an unforeseen incident with a modified SPL that has "bricked"
our devices.  I'm coming here looking for any help that anyone can
give.  Here is the information we managed to get thus far:

I have a non PVT device (e.g. DVT 2-1 or others) and now I cannot
enter bootloader / recovery.

This specific board/hardware seems to be the reason we can't use this
modified SPL.  Does anyone have any hardware engineering information
that would allow for a forced update that might save some of us a few
hundred dollars?  Please, any information would help!!
--~--~---------~--~----~------------~-------~--~----~

2. What is Port Forwarding?

"..port forwarding (so you can set up breakpoints in your code in your
IDE)"
http://developer.android.com/guide/developing/debug-tasks.html

+ Juan
--~--~---------~--~----~------------~-------~--~----~

3. Obtaining application usage data

4. "Corrupt XML binary file" error when adding a PNG to res/drawable

5. How can I install Hello world project to G1 phone? How can I install using Eclipse with ADT??

6. 'system.out.println' dumpage

7. Wonder if they will do an android course?