On Mon, Sep 6, 2010 at 8:19 PM, xi developer <[email protected]>wrote:

> I am new in Android development, I got a simple question to ask,
> I know the way how to implement item insert to DB table when there is
> only one id column and one "name" column in the table, which is:
>
> "CREATE TABLE  myTable (id INTEGER PRIMARY KEY, name TEXT)"
> String INSERT = "insert into myTable  (name) values(?)";
> SQLiteStatement insertStmt = db.compileStatement(INSERT);
> insertStmt.bindString(1, name);
> Id = insertStmt.executeInsert();
>
>
> But how about there are multiple columns (more than 2 columns) in the
> table, how to implement the insert function?? For example  I have a
> TABLE (myTable) has the following columns:
>
> "CREATE TABLE  myTable (id INTEGER PRIMARY KEY, date TEXT, time TEXT,
> cost DOUBLE)"''
>

You can follow the same procedure.

Strubg INSERT = "insert into myTable(date, time, cost) values (?,?,?)";
SQLiteStatement insertStmt = db.compileStatement(INSERT);

then use the corresponding bind statements.


> Now, I want to use SQLiteStatement to insert a item to this table, how
> to do that?
>
> --
> 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