title: Android SQLiteOpenHelper: Why onCreate() method is not called?
body: <p>I am trying to make my first Android app. I noticed that the <code>SQLiteOpenHelper.onCreate()</code> method is not called to create tables if the database not exists. However, the <code>onCreate()</code> method did not work even thought I tried to debug. </p>
  
  <p>Please look at the code below and give me any suggestions. Any help will be appreciated.</p>
  
  <pre><code>public class NameToPinyinActivity extends Activity {
  
      DatabaseOpenHelper helper = null;
  
      @Override
      public void onCreate(Bundle savedInstanceState) {
          super.onCreate(savedInstanceState);
          setContentView(R.layout.nametopinyin);
  
          Button searchButton = (Button) findViewById(R.id.search);
          searchButton.setOnClickListener(new ButtonClickListener());
  
          helper = new DatabaseOpenHelper(NameToPinyinActivity.this);
      }
  
  public class DatabaseOpenHelper extends SQLiteOpenHelper {
  
      /** DB Name */
      private static final String DB_NAME = "pinyin";
  
      /** CREATE TABLE SQL */
      private static final String CREATE_TABLE_SQL = "CREATE TABLE UNICODE_PINYIN"
              + "(ID INTEGER PRIMARY KEY AUTOINCREMENT, "
              + "UNICODE TEXT NOT NULL, PINYIN TEXT NOT NULL)";
  
      public DatabaseOpenHelper(Context context) {
          super(context, DB_NAME, null, 1);
      }
  
      @Override
      public void onCreate(SQLiteDatabase db) {
          db.beginTransaction();
          try {
              db.execSQL(CREATE_TABLE_SQL);
              db.setTransactionSuccessful();
          } catch (Exception e) {
              e.printStackTrace();
          } finally {
              db.endTransaction();
          }
      }
  </code></pre>