Then use multiple question marks. Or, better yet, use the insert()
method to insert data into a database:
public void insert(String name, String address, String type, String notes) {
ContentValues cv=new ContentValues();
cv.put("name", name);
cv.put("address", address);
cv.put("type", type);
cv.put("notes", notes);
getWritableDatabase().insert("restaurants", "name", cv);
}
On Fri, Jul 1, 2011 at 9:01 AM, NaveenShrivastva
<[email protected]> wrote:
>
>
> On Fri, Jul 1, 2011 at 5:55 PM, Mark Murphy <[email protected]> wrote:
>>
>> Use rawQuery() with ? placeholders rather than trying to concatenate
>> everything yourself. Android and SQLite will properly quote and escape
>> any strings as necessary.
>>
>> On Fri, Jul 1, 2011 at 8:13 AM, NaveenShrivastva
>> <[email protected]> wrote:
>> > Sir my sql statement is
>> > String sql = "insert into tblLocations (locType,locUrl,refUuid)
>> > values ("+
>> >
>> > map.get("type").toString()+","+map.get("URL").toString()+","+refuuid+")";
>> >
>> > getting value from hashmap then inserting .What is mistake hare .please
>> > help
>> > me
>> >
>> >
>> >
>> > On Fri, Jul 1, 2011 at 5:40 PM, NaveenShrivastva
>> > <[email protected]> wrote:
>> >>
>> >> Thx sir i am trying
>> >>
>> >> On Fri, Jul 1, 2011 at 5:33 PM, Mark Murphy <[email protected]>
>> >> wrote:
>> >>>
>> >>> You need to quote your strings, as you do in just about every SQL
>> >>> database ever invented.
>> >>>
>> >>> On Fri, Jul 1, 2011 at 7:56 AM, naveen kumar
>> >>> <[email protected]> wrote:
>> >>> > Caused by: android.database.sqlite.SQLiteException: unrecognized
>> >>> > token: ":": , while compiling: insert into tblShows
>> >>> > (shIcon,shSummary,shGenres,shName,shType,shUuid,localIcon) values
>> >>> >
>> >>> > (http://a725.phobos.apple.com/us/r1000/054/Video/e4/50/b7/mzl.qynukdwm.
>> >>> > 133x100-99.jpg,,Comedy,30 Rock,tv,S00281,show_S00281.png)
>> >>> >
>> >>> > --
>> >>> > 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
>> >>> >
>> >>>
>> >>>
>> >>>
>> >>> --
>> >>> Mark Murphy (a Commons Guy)
>> >>> http://commonsware.com | http://github.com/commonsguy
>> >>> http://commonsware.com/blog | http://twitter.com/commonsguy
>> >>>
>> >>> _Android Programming Tutorials_ Version 3.5 Available!
>> >>>
>> >>> --
>> >>> 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
>> >>
>> >>
>> >> --
>> >> Naveen Shrivastava
>> >> BCA+MCA(LAST SEM)+O/A/B Level(DOEACC SOCITY IT GOVT INDIA)
>> >>
>> >
>> >
>> >
>> > --
>> > Naveen Shrivastava
>> > BCA+MCA(LAST SEM)+O/A/B Level(DOEACC SOCITY IT GOVT INDIA)
>> >
>> > --
>> > 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
>>
>>
>>
>> --
>> Mark Murphy (a Commons Guy)
>> http://commonsware.com | http://github.com/commonsguy
>> http://commonsware.com/blog | http://twitter.com/commonsguy
>>
>> _Android Programming Tutorials_ Version 3.5 Available!
>>
>> --
>> 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
>
> Hello sir,
>
> Please refer the link
>
> http://sagistech.blogspot.com/2010/07/notes-on-android-sqlite-bukl-insert.html
>
> This example have only one table column.
>
> i want to use many columns for bind
>
> db =
> openOrCreateDatabase("dvrAppDb.sqlite",SQLiteDatabase.CREATE_IF_NECESSARY,null);
>
> db.beginTransaction();
>
> SQLiteStatement insert = null;
> try {
> String sql = "insert into tblShows
> (shIcon,shSummary,shGenres,shName,shType,shUuid,localIcon) values
> (?,?,?,?,?,?,?)";
> insert = db.compileStatement(sql);
>
> System.out.println("sssssssssssssssssssssssssssssssss======"+sql);
>
>
> for (int i = 0; i < shIconArr.size(); i++) {
>
>
> insert.bindString(i,shIconArr.get(i));
> insert.bindString(shSummaryArr.get(i));//here facing issue for
> interface
> ,shGenresArr.get(i),shNameArr.get(i), shTypeArr.get(i),
> shUuidArr.get(i),shlocalIconArr.get(i) );
>
> insert.executeInsert();
>
> db.setTransactionSuccessful();
>
> }
> } catch (SQLException e) {
> // TODO Auto-generated catch block
> e.printStackTrace();
> }
> finally
> {
> db.endTransaction();
> db.close();
> }
>
> Please help me
>
> --
> 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
--
Mark Murphy (a Commons Guy)
http://commonsware.com | http://github.com/commonsguy
http://commonsware.com/blog | http://twitter.com/commonsguy
_Android Programming Tutorials_ Version 3.5 Available!
--
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