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. display dialog box after every 5 min

Hi All,

I need help.
I want to show dialog box in my activity at regular interval of 5 min.
Thanks in advance...

-- 
Regards,
Narendra
.

-- 

2. facebook session persists in my app even after logging out of the facebook app

I have integrated the Facebook SDK in my app using the official
facebook connect API. I am able to login to the facebook app via my
app and the whole single sign on thing works fine.

The problem is coming when I logout of the installed facebook app, the
session still persists in my app and I can still post messages.
Logging out of the facebook app does not affect my app. If I go into
the manage applications and clear cache of my application then the
session is also removed from my app. Can anybody help me figure out
how logging out of the facebook app should clean the session from my
app as well??

-- 

3. Problems alloweing self-signed certificates.

4. cara ngilangin (hide) di galery

5. Rooted, whats next? WAS: pilih z4root or SuperOneClick utk Galaxy tab?

6. Very OOT. Apakah HP Android juga spt ini? Palomitas_al_movil.wmv

7. How to provide Complex rendering support in android