If you store the phone number as a pure numeric, it will be stored and retrieved that way, no problem.
If you store a number as 555-1212, I **think** SQLite will choke on the "-" in the middle while doing numeric conversion and store it as character data. If you store a number as -123245, SQLite will store that as a negative integer. But if you store a number as +12345, SQLite will store it as a positive integer and the "+" will be missing on retrieval. Whether you need to strip the quotes from the retrieved value depends, I suspect, on how you retrieve the value. If you retrieve the full query result string and parse that the quotes will be there, but I **think** there are ways to return individual column results in Java (getting my Java and C++ mixed up here, so a little foggy), such that the "stripped" value is returned as the appropriate String or int. On Jul 25, 4:30 am, YuviDroid <[email protected]> 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 > <[email protected]>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 <[email protected]> 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 <[email protected]> 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 <[email protected]> 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 [email protected] > > To unsubscribe from this group, send email to > > [email protected]<android-developers%[email protected]> > > 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 [email protected] To unsubscribe from this group, send email to [email protected] For more options, visit this group at http://groups.google.com/group/android-developers?hl=en

