title: SQLite database in Android, causes application crash
body: <p>I'm testing SQLite database in android for the first time.
  My program stops as I open it, and i cannot check it, i was wondering if there is a mistake in my code, or database connection,</p>
  
  <p>any help will be appreciated :)</p>
  
  <p>this is my Main.java file:</p>
  
  <pre><code>    package de.blattsoft.SQLite;
  
  import android.os.Bundle;
  import android.app.Activity;
  import android.database.Cursor;
  import android.database.sqlite.SQLiteDatabase;
  import android.util.Log;
  import android.view.Menu;
  
  public class Main extends Activity {
  
      @Override
      protected void onCreate(Bundle savedInstanceState) {
          super.onCreate(savedInstanceState);
          setContentView(R.layout.main);
  
          SQLiteDatabase db = openOrCreateDatabase("MyDB", MODE_PRIVATE, null);
          Cursor c = db.rawQuery("SELECT * FROM MyTable", null);
          c.moveToFirst();
          Log.d("Ali", c.getString(c.getColumnIndex("FirstName")));
          db.close();
      }
  
      @Override
      public boolean onCreateOptionsMenu(Menu menu) {
          // Inflate the menu; this adds items to the action bar if it is present.
          getMenuInflater().inflate(R.menu.main, menu);
          return true;
      }
  
  }
  </code></pre>
  
  <blockquote>
    <p>Note: I have asked this question many times ago, and I have written the full answer of how to implement databases in Android in the answers bellow.</p>
  </blockquote>