title: Android sqlite insert data SQLiteException
body: <pre><code>    @Override
      public void onCreate(SQLiteDatabase db) {
          db.execSQL(DATABASE_CREATE);
          // providers data
  //      db.execSQL("insert  into "
  //              + TABLE_PROVIDERS
  //              + " (_id, provider_id, parent_id, title, image, sh_n, enable, visible, image_bg, type, is_group, hide_in_search, limit_min, limit_max, off_on_line, invoice_search) "
  //              + "VALUES (1,600,101,'Источники оплаты','',1,1,0,'','',1,1,0,0,0,0)");
  
          ContentValues cv = new ContentValues();
          cv.put("_id", 1);
          cv.put("provider_id", 600);
          cv.put("parent_id", 101);
          cv.put("title", "Bla");
          cv.put("image", "bla");
          cv.put("sh_n", 1);
          cv.put("enable", 1);
          cv.put("visible", 1);
          cv.put("image_bg", "");
          cv.put("type", "");
          cv.put("is_group", 1);
          cv.put("hide_in_search", 1);
          cv.put("limit_min", 10);
          cv.put("limit_max", 10000);
          cv.put("off_on_line", 1);
          cv.put("invoice_search", 1);
  
          db.insertOrThrow(TABLE_PROVIDERS, null, cv);
  }
  </code></pre>
  
  <p>Now I'm doing as was suggested, inserting row by row:</p>
  
  <pre><code>import java.util.*;
  
  import android.content.*;
  import android.database.*;
  import android.database.sqlite.*;
  
  public class ProviderDataSource {
  
      private SQLiteDatabase database;
      private MySQLiteHelper dbHelper;
  
      public ProviderDataSource(Context context) {
          dbHelper = new MySQLiteHelper(context);
      }
  
      public void open() throws SQLException {
          database = dbHelper.getWritableDatabase();
      }
  
      public void close() {
          dbHelper.close();
      }
  
      public List&lt;Provider&gt; getProvidersByParentId(long parentId) {
  
          List&lt;Provider&gt; providersList = new ArrayList&lt;Provider&gt;();
  
          Cursor cursor = database.query(MySQLiteHelper.TABLE_PROVIDERS, new String[] { "provider_id", "title", "image" }, " parent_id=" + parentId,
                  null, null, null, null);
  
          cursor.moveToFirst();
          while (!cursor.isAfterLast()) {
              Provider provider = cursorToProvider(cursor);
              providersList.add(provider);
              cursor.moveToNext();
          }
          cursor.close();
          System.out.println("getProvidersByParentId");
          return providersList;
      }
  
      private Provider cursorToProvider(Cursor cursor) {
  
          Provider provider = new Provider();
          provider.setId(cursor.getInt(1));
          provider.setTitle(cursor.getString(3));
          provider.setImg(cursor.getString(4));
  
          return provider;
  
      }
  
  }
  </code></pre>
  
  <p>It doesn't work. It seems like the row wasn`t inserted and the array returnd by getProvidersByParentId method is empty. Parent_id as argument is 101. </p>