title: insert JSON array data in database table
body: <p>I've searched all around the web for a similar question as what i want but i couldn't find any. 
  So, I made an app where i get news data from JSON and display it in a list, it's all good, but now i want to add something to it, when there is no internet connection i want to display the latest list viewed. to do this i thought of storing the JSON arraylist in a databases and update it whenever the news change while there's a connection so when there's no connection it'll display the data in the database. 
  the thing is I'm kind of lost on how to do this..</p>
  
  <p>I made a java class called NewsDBHelper where i create my database and table.</p>
  
  <pre><code>public class NewsDBHelper extends SQLiteOpenHelper {
  
  public static final String LOG_TAG = NewsDBHelper.class.getSimpleName();
  
  private static final String DATABASE_NAME = "news.db";
  
  private static final int DATABASE_VERSION = 1;
  
  public NewsDBHelper(Context context) {
      super(context, DATABASE_NAME, null, DATABASE_VERSION);
  }
  @Override
  public void onCreate(SQLiteDatabase db) {
      String SQL_CREATE_PRODUCTS_TABLE = "CREATE TABLE " + Contract.NewsEntry.TABLE_NAME + " ("
              + Contract.NewsEntry._ID + " INTEGER PRIMARY KEY AUTOINCREMENT, "
              + Contract.NewsEntry.COLUMN_SECTION + " TEXT NOT NULL, "
              + Contract.NewsEntry.COLUMN_TITLE + " TEXT NOT NULL,  "
              + Contract.NewsEntry.COLUMN_DATE + " BLOB, "
              + Contract.NewsEntry.COLUMN_AUTHOR + " TEXT DEFAULT NULL, "
              + Contract.NewsEntry.COLUMN_URL + " BLOB);";
  
      Log.v(LOG_TAG,SQL_CREATE_PRODUCTS_TABLE);
      db.execSQL(SQL_CREATE_PRODUCTS_TABLE);
  }
  </code></pre>
  
  <p>Then in my mind the idea is when the JSON data are stored in an array, i'd take the array values and store them in the table. </p>
  
  <pre><code>private static List&lt;News&gt; extractFeatureFromJson(String newsJSON) {
      if (TextUtils.isEmpty(newsJSON)) {
          return null;
      }
  
      List&lt;News&gt; news = new ArrayList&lt;&gt;();
  
      try {
          JSONObject baseJsonResponse = new JSONObject(newsJSON);
          String response = baseJsonResponse.getString("response");
          JSONObject object = new JSONObject(response);
          ;
          JSONArray newsArray = object.getJSONArray("results");
          for (int i = 0; i &lt; newsArray.length(); i++) {
              JSONObject currentNews = newsArray.getJSONObject(i);
              String title = currentNews.getString("webTitle");
              String section = currentNews.getString("sectionName");
              String date = currentNews.getString("webPublicationDate");
              JSONArray tag = currentNews.getJSONArray("tags");
              String author = null;
              if (tag.length() != 0) {
                  author = tag.getJSONObject(0).getString("firstName");
              }
              String url = currentNews.getString("webUrl");
  
              News nNews = new News(title, date, section, author, url);
  
              news.add(nNews);
  
              //add news array in the table
          }
  
      } catch (JSONException e) {
          Log.e("QueryUtils", "Problem parsing the news JSON results", e);
      }
      return news;
  }
  </code></pre>
  
  <p>i don't really know how to do this or if it's possible even. if it is how can i do it? or what's the best way to implement my idea? </p>