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. is it possible to receive incoming call automatically?

There is no correct way, at this point in time.

Your approach may work (assuming the security model does not prohibit
you), but it may also break when the next Android update is released.









--~--~---------~--~----~------------~-------~--~----~

2. Is it possible to create custom theme?

Is it possible to create custom theme? And give its properties such as
window type, background color, font size, etc?
Karthik

--~--~---------~--~----~------------~-------~--~----~

3. Will we need Android OS in the near future?

4. DatePicker and calender in android ?

5. Returning a value from TabActivity.

6. time of outgoing SMS

7. Icon and text on button