Sorry if I reply so late, but I wasn't at home. I can't manage it
work. The cursor.getString() method returns me the string with the
quote.
I used single quote ' but I also tried using double quotes " .

My method of stripping the quotes back works, but now I am so curious
of getting it work properly...

I also tried to open the source code but I didn't find it.
I'm pretty sure the quotes are not stripped when it retrieves the data
in CursorWindow (but I am quite new to this java stuff, I can be
wrong) whereas I got lost in the insert part (but it looks like it
prepares the statement with the data I pass to it).

If you want to check, I can write a simplified version of the code
that's not working for me.

I got a

  public long addNumber(String number)
  {

            ContentValues contentValues = new ContentValues();
            contentValues.put(NUMBER_DESC_KEY, number);
            return db.insert(NUMBERS_TABLE, null, contentValues);
  }


and a


  public Cursor getAllNumbers () {
    return db.query(NUMBERS_TABLE, new String[] {ROW_ID,
                                                                                
          NUMBER_DESC_KEY},
                    null, null, null, null, null);
  }


and this is the test that fails:

public void testAddnumberFails(){
                String input = "'+39123123231'";
                db.open();
                db.addNumber(input);
                db.close();

                db.open();
                Cursor c = db.getAllNumbers();

                if(c.moveToFirst()){
                        do{
                                String number = 
c.getString(DbAdapter.NUMBER_DESC_COLUMN);
                                assertTrue("Number different", 
number.equals(input));
                        }while(c.moveToNext());
                }
        }


Where db is a DbHelper class as described in many tutorials.
The table was created with CALL_NUMBER_DESC_KEY field as a string.

DATABASE_NUMBERS_CREATE = "create table " +
  NUMBERS_TABLE + " (" + ROW_ID +
  " integer primary key autoincrement, " +
  NUMBER_DESC_KEY + " string);";





On 25 Lug, 15:39, DanH <danhi...@ieee.org> wrote:
> Yeah, AbstractCursor.getString() should return the "stripped" string
> value, if the appropriate quotes were used going in.
>
> On Jul 25, 4:30 am, YuviDroid <yuvidr...@gmail.com> wrote:
>
> > What do you mean by "remove the quotes"?
> > I store phone numbers on db and it works fine without dealing with adding
> > quotes, then removing them.
> > When I add/update stuff I use:
>
> > contentValues.put(TableKeys.PHONE_NUMBER, phoneNumber);
>
> > and when retrieving:
> > String phoneNumber =
> > cursor.getString(cursor.getColumnIndexOrThrow(TableKeys.PHONE_NUMBER));
>
> > Uhm...maybe I misunderstood the whole problem here..:S:S
>
> > Tra l'altro ciaoo!! ;)
> > Yuvi
>
> > On Sun, Jul 25, 2010 at 10:05 AM, Federico Paolinelli 
> > <fedep...@gmail.com>wrote:
>
> > > Just to add more information to anybody who is interested in this
> > > topic, it is necessary to remove the quotes if you need the original
> > > data.
>
> > > On 25 Lug, 09:17, Federico Paolinelli <fedep...@gmail.com> wrote:
> > > > Thanks a lot. You saved me from doing an ugly filth :-) .
> > > > I didn't expect that the number with a + was suitable to be
> > > > interpreted as a number.
>
> > > > Thanks again, Federico
>
> > > > On Jul 25, 12:50 am, DanH <danhi...@ieee.org> wrote:
>
> > > > > Did you put quotes around the string?  If SQLite sees an un-quoted
> > > > > string it's going to interpret it as numeric if possible.  SQLite
> > > > > ignores the data type of columns.
>
> > > > > On Jul 24, 5:12 pm, Federico Paolinelli <fedep...@gmail.com> wrote:
>
> > > > > > I spent a lot of time on this.
>
> > > > > > I was trying to store an incoming call number in sqlite. I'm in
> > > Italy,
> > > > > > so the number was something like +39123123.
>
> > > > > > What happened was that after putting and removing it from sqlite as 
> > > > > > a
> > > > > > string , the leading "+" was gone.
>
> > > > > > In the table creation the record is a string.
> > > > > > I call ContentValues.put(String, String) and then I get the value
> > > from
> > > > > > the cursor using getString().
>
> > > > > > Moreover; I tried to put something before the "+", like
> > > "aa+39123123",
> > > > > > the query returns the expected value. I suspect that for some reason
> > > > > > sqlite converts the String to a number, and when returns it back the
> > > +
> > > > > > is not given back.
>
> > > > > > What I think I am going to do (even if I am disgusted) is to add
> > > > > > something to the string and remove it later.
>
> > > > > > Anyway, does anybody has an explanation??
> > > > > > Many thanks in advance,
>
> > > > > > Federico
>
> > > --
> > > You received this message because you are subscribed to the Google
> > > Groups "Android Developers" group.
> > > To post to this group, send email to android-developers@googlegroups.com
> > > To unsubscribe from this group, send email to
> > > android-developers+unsubscr...@googlegroups.com<android-developers%2bunsubscr...@googlegroups.com>
> > > For more options, visit this group at
> > >http://groups.google.com/group/android-developers?hl=en
>
> > --
> > YuviDroid
> > Check out Launch-X <http://android.yuvalsharon.net/launchx.php> (a widget to
> > quickly access your favorite apps and 
> > contacts!)http://android.yuvalsharon.net

-- 
You received this message because you are subscribed to the Google
Groups "Android Developers" group.
To post to this group, send email to android-developers@googlegroups.com
To unsubscribe from this group, send email to
android-developers+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en

Reply via email to