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