title: How can i insert an array with 5 elements to db table using SQL in javascript?
body: <p>Currently am inserting one single value into db using SQL in javascript (Phonegap application)</p>
  
  <p>the following code am using to insert a value into db.</p>
  
  <p>But when i tried to run that INSERT query in a loop it showing memory issues like 2.05GB memory used on run time</p>
  
  <pre><code>    function populateDB(tx) {
  
      var newsArray=new Array();
      newsArray[0]="one";
      newsArray[1]="two";
      newsArray[2]="three";
      newsArray[3]="four";
      newsArray[4]="five";
       tx.executeSql('DROP TABLE IF EXISTS NEWS');
   tx.executeSql('CREATE TABLE IF NOT EXISTS NEWS (id PRIMARY KEY AUTO INCREMENT ,news TEXT NOT NULL)');
  var i=0;
  while(i&lt;newsArray.length){
  
  
   tx.executeSql('INSERT INTO NEWS (news) VALUES ('newsArray[i]')');
      i++;
  }
  
                  //Dropping and adding makes sure there is one entry of the news item.
                  //You may actually cache multiple copies and make it a feature as well.
  }
  </code></pre>