Hi, sorry about the variable names aren't consistent.
I change it when I paste here to make it readable, my mistake for the
confusion.
About the single code, I want the value of temp instead of the string
"temp" ('temp') therefore I have not single code.
Many thanks.
On Sep 16, 2:28 pm, String <[email protected]> wrote:
> You're missing the inner (single) quotes around the temp string. Also,
> your variable names aren't consistent, but I'm assuming that's just in
> your post here - the compiler would have caught that for you. In any
> case, your code should be:
>
> String temp = "temp";
> db.execSQL("INSERT INTO " + TABLE_NAME + " VALUES (0 'A',
> 'Hello', '', '" + temp + "', '');");
>
> On Sep 16, 6:37 am, Mystique <[email protected]> wrote:
>
>
>
> > Hi,
>
> > I want to insert a String value call temp but I don't seems to get it
> > working for the INSERT INTO statement.
> > Anything wrong with the code?
>
> > This is the initialization to create table and insert some default
> > values into the table if the database doesn't exist.
>
> > Many Thanks.
>
> > ---code---
> > @Override
> > public void onCreate(SQLiteDatabase db) {
> > db.execSQL("CREATE TABLE " + TABLE_NAME + " (" + _ID
> > + " INTEGER PRIMARY KEY AUTOINCREMENT, " + FIELD1 + "
> > VARCHAR(1), " + FIELD2
> > + " TEXT, " + FIELD3 + " TEXT, " + FIELD4 + " TEXT, " +
> > FIELD5 + " TEXT);");
>
> > String tmp = "temp";
> > db.execSQL("INSERT INTO " + TABLE_NAME + " VALUES (0 'A',
> > 'Hello', '', " + temp + ", '');");
> > }
> > ---code---
--
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