Read the documentation carefully:

"In SQLite, the datatype of a value is associated with the value
itself, not with its container."

"Any column in an SQLite version 3 database, except an INTEGER PRIMARY
KEY column, may be used to store a value of any storage class."

There is what they call "affinity", but it does not affect how a value
is interpreted in the query statement, only conversions that occur
after it's initially interpreted.

I've not used the Android interfaces, but with the standard
java.sql.ResultSet updateString/getString interface there's no need to
explicitly quote string values, or strip the quotes on retrieval.

Here's the code I've used for constructing an INSERT statement (since
oddly none of the APIs support a ResultSet style interface for
INSERT):

                StringBuffer stmt = new StringBuffer();
                stmt.append("INSERT INTO ");
                if ((schemaName != null) && (schemaName.length() > 0)) {
                        stmt.append(schemaName);
                        stmt.append(".");
                }
                stmt.append(tableName);
                stmt.append(" VALUES (");
                for (int i = 0; i < columnValues.length; i++) {
                        if (columnValues[i] instanceof String) {
                                stmt.append("'");
                                
stmt.append(doubleQuotes(columnValues[i].toString()));
                                stmt.append("'");
                        }
                        else {
                                stmt.append(columnValues[i].toString());
                        }
                        if (i+1 == columnValues.length) {
                                stmt.append(")");
                        }
                        else {
                                stmt.append(", ");
                        }
                }


(Implementing method doubleQuotes is left as an exercise for the
student.)

On Jul 25, 2:24 pm, Dmitri Plotnikov <[email protected]> wrote:
> This should not be happening if the column type is declared correctly.  It
> should be declared as TEXT.  Seehttp://www.sqlite.org/datatype3.html
>
> Cheers,
> Dmitri
> On Jul 25, 2010 12:14 PM, "Federico Paolinelli" <[email protected]> wrote:
>
> > That's what I did, as I said before:
>
> > "What I think I am going to do (even if I am disgusted) is to add
> > something to the string and remove it later. "
>
> > but I thought there was a more standard way to do it as suggested by Dan
>
> > 2010/7/25 Kostya Vasilyev <[email protected]>:
> >> Why not prefix the number with some arbitrary, predefined character?
>
> >> Sort of like the leading single quote in Excel.
>
> >> Then remove it after getting the value from the database.
>
> >> Just make sure it's not a valid phone number character - like, any letter
> >> from A to Z will work...
>
> >> --
> >> Kostya Vasilyev --http://kmansoft.wordpress.com
>
> >> 25.07.2010 22:26 пользователь "Federico Paolinelli" <[email protected]>
> >> написал:
>
> >> As Dan stated, the problem is the leading + of an international number
> >> that gets lost in the insert / get process.
>
> >> If I put a number like "+39123123", when I perform a getString I get
> >> back something like 39123123, this is because sqllite thinks it is a
> >> pure number.
>
> >> (Ciao anche a te)
>
> >> On 25 Lug, 11:30, YuviDroid <[email protected]> wrote:
> >>> What do you mean by "remove the quotes"?...
>
> >>> 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 necessa...
>
> >>> > [email protected]<android-developers%[email protected]>
>
> <android-developers%[email protected]<android-developers%[email protected]>
>
>
>
> >>> > For more options, visit this group at
> >>> >http://groups.google.com/group/android-developers?hl=en...
>
> >>> 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 t...
>
> >> --
> >> 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
>
> > --
> > --------
> > 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

-- 
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

Reply via email to