[SOLVED]DB cursor.getString() Problem

Problems with WiFi, SQLite ,Bluetooth, WiMax, Proxies, etc...

[SOLVED]DB cursor.getString() Problem

Postby bonny » Thu Dec 18, 2008 10:34 am

Hi,
I have a problem with this part of code. I'm writing an app that should parse an xml and add parsed data to a db, checking (If the row is already present) if a certain parsed value (an md5) is equal to the md5 already present in the db.This is the part of code that causes problems:

Code: Select all
Cursor pCursor = Contacts.ProfilemDbHelper.fetchMd5(ManageContact.SubStringJid(getJid()));
Log.v("CURSOR", String.valueOf(pCursor.getCount()));
String pMd5 = pCursor.getString(pCursor.getColumnIndex(ProfileDbAdapter.KEY_MD5));


The problem is that when program arrive to pCursor.getString I receive in the LogCat this error:
Code: Select all
12-18 10:19:03.961: VERBOSE/CURSOR(189): 1
12-18 10:19:03.971: VERBOSE/PARSECONTACT(189): Error: Index -1 requested, with a size of 1


Contacts is the activity where I work, but this part of code is in another class (The class of parsedData).The first row in the logCat returns 1, that is the number of rows in the cursor, so I'm sure that the row is already present. The second row in logcat is the error I receive, and I don't know how to solve it, because pCursor.getColumnIndex return the right value. Any ideas?

Please help me, it's quite urgent.
Last edited by bonny on Thu Dec 18, 2008 12:51 pm, edited 1 time in total.
bonny
Junior Developer
Junior Developer
 
Posts: 19
Joined: Fri Apr 11, 2008 2:08 pm

Top

Postby MrSnowflake » Thu Dec 18, 2008 12:37 pm

Always do
Syntax: [ Download ] [ Hide ]
Using java Syntax Highlighting
  1. if (cursor.moveToFirst() {
  2.  
  3.      // Your good now!
  4.  
  5. }
Parsed in 0.031 seconds, using GeSHi 1.0.8.4
User avatar
MrSnowflake
Moderator
Moderator
 
Posts: 1439
Joined: Sat Feb 16, 2008 3:11 pm
Location: Flanders, Belgium

Postby bonny » Thu Dec 18, 2008 12:44 pm

Thank you very much!!Now it works. It was so simple..
bonny
Junior Developer
Junior Developer
 
Posts: 19
Joined: Fri Apr 11, 2008 2:08 pm

Top

Return to Networking & Database Problems

Who is online

Users browsing this forum: No registered users and 6 guests