title: When click button VerEstoque, the application stops. Logcat error is on code, please h3lp
body: <p>Logcat error: since i click to play emulate</p>
  
  <pre><code>07-28 23:16:56.813    2367-2367/kabashima.materiaisdeconstrucaoconcept   W/EGL_genymotion﹕ eglSurfaceAttrib not implemented
  07-28 23:16:58.493    2367-2367/kabashima.materiaisdeconstrucaoconcept D/dalvikvm﹕ GC_FOR_ALLOC freed 133K, 6% free 4119K/4356K, paused 2ms, total 2ms
  07-28 23:16:58.493    2367-2367/kabashima.materiaisdeconstrucaoconcept D/dalvikvm﹕ GC_FOR_ALLOC freed 28K, 6% free 4311K/4580K, paused 2ms, total 2ms
  07-28 23:16:58.497    2367-2367/kabashima.materiaisdeconstrucaoconcept I/dalvikvm-heap﹕ Grow heap (frag case) to 6.725MB for 2536932-byte allocation
  07-28 23:16:58.501    2367-2376/kabashima.materiaisdeconstrucaoconcept D/dalvikvm﹕ GC_FOR_ALLOC freed &lt;1K, 4% free 6788K/7060K, paused 3ms, total 3ms
  07-28 23:16:58.645    2367-2367/kabashima.materiaisdeconstrucaoconcept D/dalvikvm﹕ GC_FOR_ALLOC freed 152K, 4% free 7731K/7984K, paused 3ms, total 3ms
  07-28 23:16:58.709    2367-2367/kabashima.materiaisdeconstrucaoconcept D/dalvikvm﹕ GC_FOR_ALLOC freed 172K, 3% free 8970K/9244K, paused 3ms, total 3ms
  07-28 23:16:58.777    2367-2367/kabashima.materiaisdeconstrucaoconcept D/dalvikvm﹕ GC_FOR_ALLOC freed 383K, 5% free 10411K/10896K, paused 4ms, total 4ms
  07-28 23:16:58.873    2367-2367/kabashima.materiaisdeconstrucaoconcept D/dalvikvm﹕ GC_FOR_ALLOC freed 344K, 4% free 12369K/12816K, paused 4ms, total 4ms
  07-28 23:16:58.993    2367-2367/kabashima.materiaisdeconstrucaoconcept D/dalvikvm﹕ GC_FOR_ALLOC freed 0K, 1% free 14567K/14672K, paused 7ms, total 7ms
  07-28 23:16:59.149    2367-2367/kabashima.materiaisdeconstrucaoconcept D/dalvikvm﹕ GC_FOR_ALLOC freed 517K, 4% free 17737K/18356K, paused 7ms, total 7ms
  07-28 23:16:59.341    2367-2367/kabashima.materiaisdeconstrucaoconcept D/dalvikvm﹕ GC_FOR_ALLOC freed 775K, 4% free 21706K/22584K, paused 9ms, total 9ms
  07-28 23:16:59.573    2367-2367/kabashima.materiaisdeconstrucaoconcept D/dalvikvm﹕ GC_FOR_ALLOC freed 1163K, 5% free 26610K/27876K, paused 11ms, total 11ms
  07-28 23:16:59.905    2367-2367/kabashima.materiaisdeconstrucaoconcept D/dalvikvm﹕ GC_FOR_ALLOC freed 0K, 1% free 32990K/33092K, paused 16ms, total 16ms
  07-28 23:17:00.213    2367-2367/kabashima.materiaisdeconstrucaoconcept D/dalvikvm﹕ GC_FOR_ALLOC freed 1745K, 5% free 39436K/41284K, paused 18ms, total 18ms
  07-28 23:17:00.565    2367-2367/kabashima.materiaisdeconstrucaoconcept D/dalvikvm﹕ GC_FOR_ALLOC freed 0K, 1% free 46080K/46184K, paused 22ms, total 22ms
  07-28 23:17:00.805    2367-2367/kabashima.materiaisdeconstrucaoconcept D/dalvikvm﹕ GC_FOR_ALLOC freed 2618K, 6% free 51652K/54372K, paused 22ms, total 22ms
  07-28 23:17:01.241    2367-2367/kabashima.materiaisdeconstrucaoconcept D/dalvikvm﹕ GC_FOR_ALLOC freed 0K, 1% free 59842K/59944K, paused 27ms, total 27ms
  07-28 23:17:01.561    2367-2367/kabashima.materiaisdeconstrucaoconcept D/dalvikvm﹕ GC_FOR_ALLOC freed 0K, 1% free 65715K/65820K, paused 32ms, total 32ms
  07-28 23:17:01.741    2367-2367/kabashima.materiaisdeconstrucaoconcept D/dalvikvm﹕ GC_FOR_ALLOC freed 3927K, 6% free 69979K/74008K, paused 30ms, total 30ms
  07-28 23:17:02.189    2367-2367/kabashima.materiaisdeconstrucaoconcept D/dalvikvm﹕ GC_FOR_ALLOC freed 0K, 1% free 78170K/78272K, paused 34ms, total 34ms
  07-28 23:17:02.645    2367-2367/kabashima.materiaisdeconstrucaoconcept D/dalvikvm﹕ GC_FOR_ALLOC freed 0K, 1% free 86362K/86464K, paused 38ms, total 38ms
  07-28 23:17:03.097    2367-2367/kabashima.materiaisdeconstrucaoconcept I/dalvikvm-heap﹕ Clamp target GC heap from 100.434MB to 96.000MB
  07-28 23:17:03.101    2367-2367/kabashima.materiaisdeconstrucaoconcept D/dalvikvm﹕ GC_FOR_ALLOC freed 0K, 1% free 94554K/94656K, paused 43ms, total 43ms
  07-28 23:17:03.177    2367-2367/kabashima.materiaisdeconstrucaoconcept I/dalvikvm-heap﹕ Clamp target GC heap from 101.033MB to 96.000MB
  07-28 23:17:03.177    2367-2367/kabashima.materiaisdeconstrucaoconcept D/dalvikvm﹕ GC_FOR_ALLOC freed 0K, 1% free 95167K/95272K, paused 46ms, total 46ms
  07-28 23:17:03.177    2367-2367/kabashima.materiaisdeconstrucaoconcept I/dalvikvm-heap﹕ Forcing collection of SoftReferences for 9047800-byte allocation
  07-28 23:17:03.237    2367-2367/kabashima.materiaisdeconstrucaoconcept I/dalvikvm-heap﹕ Clamp target GC heap from 101.025MB to 96.000MB
  07-28 23:17:03.237    2367-2367/kabashima.materiaisdeconstrucaoconcept D/dalvikvm﹕ GC_BEFORE_OOM freed 9K, 1% free 95157K/95272K, paused 61ms, total 61ms
  07-28 23:17:03.237    2367-2367/kabashima.materiaisdeconstrucaoconcept E/dalvikvm-heap﹕ Out of memory on a 9047800-byte allocation.
  07-28 23:17:03.237    2367-2367/kabashima.materiaisdeconstrucaoconcept I/dalvikvm﹕ "main" prio=5 tid=1 RUNNABLE
  07-28 23:17:03.237    2367-2367/kabashima.materiaisdeconstrucaoconcept I/dalvikvm﹕ | group="main" sCount=0 dsCount=0 obj=0xa4d10bd8 self=0xb8991eb0
  07-28 23:17:03.237    2367-2367/kabashima.materiaisdeconstrucaoconcept I/dalvikvm﹕ | sysTid=2367 nice=0 sched=0/0 cgrp=apps handle=-1216860096
  07-28 23:17:03.237    2367-2367/kabashima.materiaisdeconstrucaoconcept I/dalvikvm﹕ | state=R schedstat=( 4963745014 39782304 859 ) utm=460 stm=35 core=1
  07-28 23:17:03.237    2367-2367/kabashima.materiaisdeconstrucaoconcept I/dalvikvm﹕ at java.util.ArrayList.add(ArrayList.java:~118)
  07-28 23:17:03.237    2367-2367/kabashima.materiaisdeconstrucaoconcept I/dalvikvm﹕ at android.widget.ArrayAdapter.add(ArrayAdapter.java:179)
  07-28 23:17:03.237    2367-2367/kabashima.materiaisdeconstrucaoconcept I/dalvikvm﹕ at kabashima.materiaisdeconstrucaoconcept.bancodedados.dominio.RepositorioEstoque.buscaEstoque(RepositorioEstoque.java:51)
  07-28 23:17:03.237    2367-2367/kabashima.materiaisdeconstrucaoconcept I/dalvikvm﹕ at kabashima.materiaisdeconstrucaoconcept.EstoqueProdutos.onCreate(EstoqueProdutos.java:50)
  07-28 23:17:03.237    2367-2367/kabashima.materiaisdeconstrucaoconcept I/dalvikvm﹕ at android.app.Activity.performCreate(Activity.java:5231)
  07-28 23:17:03.237    2367-2367/kabashima.materiaisdeconstrucaoconcept I/dalvikvm﹕ at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1087)
  07-28 23:17:03.237    2367-2367/kabashima.materiaisdeconstrucaoconcept I/dalvikvm﹕ at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2148)
  07-28 23:17:03.237    2367-2367/kabashima.materiaisdeconstrucaoconcept I/dalvikvm﹕ at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2233)
  07-28 23:17:03.237    2367-2367/kabashima.materiaisdeconstrucaoconcept I/dalvikvm﹕ at android.app.ActivityThread.access$800(ActivityThread.java:135)
  07-28 23:17:03.237    2367-2367/kabashima.materiaisdeconstrucaoconcept I/dalvikvm﹕ at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1196)
  07-28 23:17:03.237    2367-2367/kabashima.materiaisdeconstrucaoconcept I/dalvikvm﹕ at android.os.Handler.dispatchMessage(Handler.java:102)
  07-28 23:17:03.237    2367-2367/kabashima.materiaisdeconstrucaoconcept I/dalvikvm﹕ at android.os.Looper.loop(Looper.java:136)
  07-28 23:17:03.237    2367-2367/kabashima.materiaisdeconstrucaoconcept I/dalvikvm﹕ at android.app.ActivityThread.main(ActivityThread.java:5001)
  07-28 23:17:03.237    2367-2367/kabashima.materiaisdeconstrucaoconcept I/dalvikvm﹕ at java.lang.reflect.Method.invokeNative(Native Method)
  07-28 23:17:03.237    2367-2367/kabashima.materiaisdeconstrucaoconcept I/dalvikvm﹕ at java.lang.reflect.Method.invoke(Method.java:515)
  07-28 23:17:03.237    2367-2367/kabashima.materiaisdeconstrucaoconcept I/dalvikvm﹕ at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:785)
  07-28 23:17:03.237    2367-2367/kabashima.materiaisdeconstrucaoconcept I/dalvikvm﹕ at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:601)
  07-28 23:17:03.237    2367-2367/kabashima.materiaisdeconstrucaoconcept I/dalvikvm﹕ at dalvik.system.NativeStart.main(Native Method)
  07-28 23:17:03.237    2367-2367/kabashima.materiaisdeconstrucaoconcept I/dalvikvm﹕ [ 07-28 23:17:03.237  2367: 2367 D/AndroidRuntime ]
  Shutting down VM
  07-28 23:17:03.237    2367-2367/kabashima.materiaisdeconstrucaoconcept W/dalvikvm﹕ threadid=1: thread exiting with uncaught exception (group=0xa4d0fb20)
  07-28 23:17:03.237    2367-2367/kabashima.materiaisdeconstrucaoconcept E/AndroidRuntime﹕ FATAL EXCEPTION: main
  Process: kabashima.materiaisdeconstrucaoconcept, PID: 2367
  java.lang.OutOfMemoryError
          at java.util.ArrayList.add(ArrayList.java:118)
          at android.widget.ArrayAdapter.add(ArrayAdapter.java:179)
          at kabashima.materiaisdeconstrucaoconcept.bancodedados.dominio.RepositorioEstoque.buscaEstoque(RepositorioEstoque.java:51)
          at kabashima.materiaisdeconstrucaoconcept.EstoqueProdutos.onCreate(EstoqueProdutos.java:50)
          at android.app.Activity.performCreate(Activity.java:5231)
          at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1087)
          at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2148)
          at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2233)
          at android.app.ActivityThread.access$800(ActivityThread.java:135)
          at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1196)
          at android.os.Handler.dispatchMessage(Handler.java:102)
          at android.os.Looper.loop(Looper.java:136)
          at android.app.ActivityThread.main(ActivityThread.java:5001)
          at java.lang.reflect.Method.invokeNative(Native Method)
          at java.lang.reflect.Method.invoke(Method.java:515)
          at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:785)
          at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:601)
          at dalvik.system.NativeStart.main(Native Method)
  </code></pre>
  
  <p>//Banco de dados class
      package kabashima.materiaisdeconstrucaoconcept.bancodedados;</p>
  
  <pre><code>import android.content.ContentValues;
  import android.content.Context;
  import android.database.Cursor;
  import android.database.sqlite.SQLiteDatabase;
  import android.database.sqlite.SQLiteOpenHelper;
  
  import kabashima.materiaisdeconstrucaoconcept.Contact;
  
  
  
  public class BancoDeDados extends SQLiteOpenHelper {
  
  private static final int DATABASE_VERSION = 2;
  private static final String DATABASE_NAME = "contacts.db";
  private static final String TABLE_NAME = "contacts";
  private static final String COLUMN_ID = "id";
  private static final String COLUMN_NOME = "nome";
  private static final String COLUMN_EMAIL = "email";
  private static final String COLUMN_SENHA = "senha";
  SQLiteDatabase db;
  
  private static final String TABLE_CREATE = "create table contacts(id integer primary key not null  ," +
          "nome text not null, email text not null, senha text not null);";
  
  
  
  
  public BancoDeDados(Context context){
  
  super(context, DATABASE_NAME, null, DATABASE_VERSION);
  
  
  }
  
  @Override
  public void onCreate(SQLiteDatabase db) {
  db.execSQL(TABLE_CREATE);
      db.execSQL( ScriptSQL.getCreateEstoqueProdutos());
     // db.execSQL(TABLE_CREATE2);
      this.db=db;
  
  
   }
  
  @Override
  public void onUpgrade(SQLiteDatabase db, int oldVersion, int newVersion) {
     String query = "DROP TABLE IF EXISTS" + TABLE_NAME;
      db.execSQL(query);
      this.onCreate(db);
  }
  
  public void insertContact(Contact c) {
  db = this.getWritableDatabase();
      ContentValues values = new ContentValues();
  
      String query = "select * from contacts";
      Cursor cursor = db.rawQuery(query, null);
      int count = cursor.getCount();
  
      values.put(COLUMN_ID, count);
      values.put(COLUMN_NOME, c.getNome());
      values.put(COLUMN_EMAIL, c.getEmail());
      values.put(COLUMN_SENHA, c.getSenha());
  
      db.insert(TABLE_NAME, null, values);
      db.close();
  
  
  }
  public String searchPass(String nome){
      db = this.getReadableDatabase();
      String query = "select nome, senha from " + TABLE_NAME;
      Cursor cursor = db.rawQuery(query, null);
      String a,b;
      b = "not found";
  
      if(cursor.moveToFirst()){
          do{
               a = cursor.getString(0);
                  if(a.equals(nome))
                  {
  
                  b = cursor.getString(1);
                  break;
  
              }
          }while (cursor.moveToNext());
  
      }
              return b;
  }
  }
  </code></pre>
  
  <p>//RepositorioEstoque class</p>
  
  <pre><code>package kabashima.materiaisdeconstrucaoconcept.bancodedados.dominio;
  
  import android.content.ContentValues;
  import android.content.Context;
  import android.database.Cursor;
  import android.database.sqlite.SQLiteDatabase;
  import android.widget.ArrayAdapter;
  
  
  public class RepositorioEstoque {
  private SQLiteDatabase conn;
  
  public RepositorioEstoque(SQLiteDatabase conn) {
      this.conn = conn;
  }
  
  public void TesteInserirProdutos() {
  
      for (int i = 0; i &lt; 10; i++) {
  
          ContentValues values = new ContentValues();
          values.put("NOMEPRODUTOS", "JR");
  
          conn.insertOrThrow("ESTOQUEPRODUTOS", null, values);
  
      }
  
  }
  
      public ArrayAdapter&lt;String&gt; buscaEstoque(Context context)
  
      {
  
  
          ArrayAdapter&lt;String&gt; adpEstoque = new ArrayAdapter&lt;String&gt;(context, android.R.layout.simple_list_item_1);
  
  
          Cursor cursor = conn.query("ESTOQUEPRODUTOS",null,null,null,null,null,null);
          if (cursor.getCount() &gt; 0)
          {
              do {
  
                  cursor.moveToFirst();
  
  
                  String nome = cursor.getString(1);
                  adpEstoque.add(nome);
              } while (cursor.moveToNext());
  
  
          }
          return adpEstoque;
      }
  
  
  }
  </code></pre>
  
  <p>//EstoqueProdutos class</p>
  
  <pre><code>package kabashima.materiaisdeconstrucaoconcept;
  
  import android.app.AlertDialog;
  import android.support.v7.app.ActionBarActivity;
  import android.os.Bundle;
  import android.view.Menu;
  import android.view.MenuItem;
  import android.view.View;
  import android.widget.*;
  import android.content.*;
  import android.database.sqlite.*;
  import android.database.*;
  
  import kabashima.materiaisdeconstrucaoconcept.bancodedados.BancoDeDados;
  import kabashima.materiaisdeconstrucaoconcept.bancodedados.dominio.RepositorioEstoque;
  
  
  
  public class EstoqueProdutos extends ActionBarActivity implements View.OnClickListener{
  
  private ImageButton btnAdicionar;
  private EditText edtPesquisa;
  private ListView lstProdutos;
  private ArrayAdapter&lt;String&gt; adpEstoque;
  private BancoDeDados bancodedados;
  private SQLiteDatabase conn;
  private RepositorioEstoque repositorioEstoque;
  
  
  
  @Override
  protected void onCreate(Bundle savedInstanceState) {
      super.onCreate(savedInstanceState);
      setContentView(R.layout.estoqueprodutos);
  
      btnAdicionar = (ImageButton)findViewById(R.id.btnAdicionar);
      edtPesquisa = (EditText)findViewById(R.id.edtPesquisa);
      lstProdutos = (ListView)findViewById(R.id.lstProdutos);
  
      btnAdicionar.setOnClickListener(this);
  
      try{
          bancodedados = new BancoDeDados(this);
          conn = bancodedados.getWritableDatabase();
  
  
          repositorioEstoque = new RepositorioEstoque(conn);
          repositorioEstoque.TesteInserirProdutos();
  
          adpEstoque = repositorioEstoque.buscaEstoque(this);
  
          lstProdutos.setAdapter(adpEstoque);
          AlertDialog.Builder dlg = new AlertDialog.Builder(this);
          dlg.setMessage("Conexao criada com sucesso!");
          dlg.setNeutralButton("ok", null);
  
  
      }
  
      catch(SQLException ex)
      {
          AlertDialog.Builder dlg = new AlertDialog.Builder(this);
          dlg.setMessage("Erro ao criar o banco"+ ex.getMessage());
          dlg.setNeutralButton("ok", null);
          //MessageBox.show(this, "Erro", "Erro ao criar o banco: " + ex.getMessage() );
      }
  }
  
  
  @Override
  public boolean onCreateOptionsMenu(Menu menu) {
      // Inflate the menu; this adds items to the action bar if it is present.
      getMenuInflater().inflate(R.menu.menu_estoque_produtos, menu);
      return true;
  }
  
  @Override
  public boolean onOptionsItemSelected(MenuItem item) {
      // Handle action bar item clicks here. The action bar will
      // automatically handle clicks on the Home/Up button, so long
      // as you specify a parent activity in AndroidManifest.xml.
      int id = item.getItemId();
  
      //noinspection SimplifiableIfStatement
      if (id == R.id.action_settings) {
          return true;
      }
  
      return super.onOptionsItemSelected(item);
  }
  
  @Override
  public void onClick(View view) {
      Intent in = new Intent(this, CadastrarProdutos.class);
      startActivity(in);
  }
  </code></pre>
  
  <p>}</p>
  
  <p>//ScripSQL class</p>
  
  <pre><code>package kabashima.materiaisdeconstrucaoconcept.bancodedados;
  
  
  public class ScriptSQL {
  
  
  public static String getCreateEstoqueProdutos()
  {
  
      StringBuilder sqlBuilder = new StringBuilder();
      sqlBuilder.append(" CREATE TABLE IF NOT EXISTS ESTOQUEPRODUTOS ( ");
      sqlBuilder.append("_id                INTEGER       NOT NULL ");
      sqlBuilder.append("PRIMARY KEY AUTOINCREMENT, ");
      sqlBuilder.append("NOMEPRODUTOS         VARCHAR (200), ");
      sqlBuilder.append("MARCA                VARCHAR (200), ");
      sqlBuilder.append("LOJA                 VARCHAR (200), ");
      sqlBuilder.append("ESTOQUE              VARCHAR (10), ");
      sqlBuilder.append("VALOR                VARCHAR (30) ");
      sqlBuilder.append(");");
  
      return sqlBuilder.toString();
  
  }
  </code></pre>
  
  <p>}</p>
  
  <p>//There are the codes, cold somebody see it for me? it will help me a lot. I don't know really whats the problem =/ thanks, i will be helpful!</p>