multiple records not insert into sqllite


Last Updated:

  1. ravindra4ravi

    ravindra4ravi New Member This Topic's Starter

    Joined:
    Dec 28, 2009
    Messages:
    1
    Likes Received:
    0
    I tryed to insert multiple records in sqllite database but it insert only first record my code is here :
    Sqllitedatabase db;

    public void createTableEntry(MyDetails detail) {
    ContentValues content = new ContentValues();
    String name[],sex[],city[];
    int age[];
    name = detail.getName();
    age = detail.getAge();
    sex = detail.getSex();
    city = detail.getCity();
    for(int i = 0; i<detail.getAge().length;i++){
    content.put(KEY_NAME, name);
    content.put(KEY_AGE, age);
    content.put(KEY_SEX, sex);
    content.put(KEY_CITY, city);
    db.insert(DATABASE_TABLE, null, content);
    }
    }

    but it insert only first record

    Please help me urgently with suitable code.........

    Regards

    Ravindra
     

    Advertisement
  2. lekky

    lekky Lover VIP Member

    Joined:
    Oct 29, 2009
    Messages:
    5,252
    Likes Received:
    1,266
    You are wanting to insert a record for every age?

    Should this line:

    Code (Text):
    1. for(int i = 0; i<detail.getAge().length; i++){
    be:

    Code (Text):
    1. for(int i = 0; i<detail.getAge(); i++){
    ?
     

Share This Page

Loading...