title: Android Eclipse can't read my SQLite Database
body: <p>I always have problem with my SQLite database, anyone help to resolved?</p>
  
  <p>this is my <code>DatabaseHelper.java</code></p>
  
  <pre><code>private static final String     DB_NAME     = "msekolah";
  private static final int        DB_VER      = 1;
  
  private static final String  SD_DATA  = "sd_data";
   public static final String  COL_ID  = "_rowid";
   public static final String  COL_NAMA = "namasek";
   public static final String  COL_ALAMAT = "address";
   public static final String  COL_KELURAHAN = "kelu";
   public static final String  COL_LATI = "lat";
   public static final String  COL_LONG = "lon";
  
  private static DatabaseHelper   dbInstance;
  private static SQLiteDatabase   db;
  
  private DatabaseHelper(Context context)
  {
      super(context, DB_NAME, null, DB_VER);
  }
  
  public static DatabaseHelper getInstance(Context context)
  {
      if (dbInstance == null)
      {
          dbInstance = new DatabaseHelper(context);
  
      }
      return dbInstance;
  }
  
  @Override
  public synchronized void close()
  {
      super.close();
      if (dbInstance != null)
      {
          dbInstance.close();
      }
  }
  
  public List&lt;Kamus&gt; getAllKamus()
  {
      List&lt;Kamus&gt; lisKamus = new ArrayList&lt;Kamus&gt;();
  
      Cursor cursor = db.query(SD_DATA, new String[] { 
              COL_ID, COL_NAMA, COL_ALAMAT, COL_KELURAHAN, COL_LATI, COL_LONG }, 
              COL_ID + "=" + "_rowid",
              null, null, null, null);
            if (cursor.getCount() &gt;= 1)
      {
          cursor.moveToFirst();
  
          do
          {
              Kamus kamus = new Kamus();
              kamus.setLongitude(cursor.getString(cursor.getColumnIndexOrThrow(COL_LONG)));
              kamus.setLatitude(cursor.getString(cursor.getColumnIndexOrThrow(COL_LATI)));
              kamus.setKelurahan(cursor.getString(cursor.getColumnIndexOrThrow(COL_KELURAHAN)));
              kamus.setAlamat(cursor.getString(cursor.getColumnIndexOrThrow(COL_ALAMAT)));
              kamus.setNamaSekolah(cursor.getString(cursor.getColumnIndexOrThrow(COL_NAMA)));
              lisKamus.add(kamus);
  
          } while (cursor.moveToNext());
      }
      return lisKamus;
  
  }
  
  public Cursor getBukuByJudul(String query)
  {
      Cursor cursor = null;
  
      if (TextUtils.isEmpty(query))
      {
          cursor = db.query(SD_DATA, new String[] { COL_ID, COL_ID,
                  COL_NAMA, COL_ALAMAT, COL_KELURAHAN, COL_LATI, COL_LONG }, null, null, null, null, COL_LONG);
      } else
      {
          cursor = db.query(SD_DATA, new String[] { COL_ID, COL_NAMA, COL_ALAMAT, COL_KELURAHAN, COL_LATI, COL_LONG }, COL_LONG + " like '" + query + "%'",
                  null, null, null, null);
      }
      return cursor;
  }
  </code></pre>
  
  <p>and this is My <code>MainActivity.java</code></p>
  
  <pre><code>@Override
      protected void onCreate(Bundle savedInstanceState)
      {
          super.onCreate(savedInstanceState);
          setContentView(R.layout.activity_main);
          lv = (ListView) findViewById(R.id.lv_data);
          lv.setEmptyView(findViewById(R.id.empty));
          search = (EditText) findViewById(R.id.search);
  
          dbHelper = DatabaseHelper.getInstance(this);
  
          setData();
  
          search.addTextChangedListener(this);
          lv.setOnItemClickListener(this);
      }
  
      private void setData()
      {
          listKamus = dbHelper.getAllKamus();
  
          adapter = new ArrayAdapter&lt;Kamus&gt;(this,
                  android.R.layout.simple_expandable_list_item_1, listKamus);
          lv.setAdapter(adapter);
  
      }
  
      @Override
      public void afterTextChanged(Editable arg0)
      {
      }
  
      @Override
      public void beforeTextChanged(CharSequence arg0, int arg1, int arg2,
              int arg3)
      {
      }
  
      @Override
      public void onTextChanged(CharSequence s, int arg1, int arg2, int arg3)
      {
          adapter.getFilter().filter(s.toString());
      }
  
      @Override
      public void onItemClick(AdapterView&lt;?&gt; arg0, View arg1, int position,
              long id)
      {
          // TODO Auto-generated method stub
          Bundle b = new Bundle();
          b.putString("lon", adapter.getItem(position).getLongitude());
          b.putString("lat", adapter.getItem(position).getLatitude());
          b.putString("kelu", adapter.getItem(position).getKelurahan());
          b.putString("address", adapter.getItem(position).getAlamat());
          b.putString("namasek", adapter.getItem(position).getNamaSekolah());
  
          Intent i = new Intent(this, ArtiActivity.class);
          i.putExtras(b);
          startActivity(i);
  
      }
  
  }
  </code></pre>
  
  <p>i've tired to find the problem on Logcat 
  because of the emulator can't read my database sqlite in assets
  please help..</p>
  
  <blockquote>
    <p>04-12 18:54:45.216: E/AndroidRuntime(275): FATAL EXCEPTION: main 04-12
    18:54:45.216: E/AndroidRuntime(275): java.lang.RuntimeException:
    Unable to start activity
    ComponentInfo{id.nuhun.lbssekolah/id.nuhun.lbssekolah.MainActivity}:
    java.lang.NullPointerException 04-12 18:54:45.216:
    E/AndroidRuntime(275):    at
    android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2663)
    04-12 18:54:45.216: E/AndroidRuntime(275):    at
    android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2679)
    04-12 18:54:45.216: E/AndroidRuntime(275):    at
    android.app.ActivityThread.access$2300(ActivityThread.java:125) 04-12
    18:54:45.216: E/AndroidRuntime(275):  at
    android.app.ActivityThread$H.handleMessage(ActivityThread.java:2033)
    04-12 18:54:45.216: E/AndroidRuntime(275):    at
    android.os.Handler.dispatchMessage(Handler.java:99) 04-12
    18:54:45.216: E/AndroidRuntime(275):  at
    android.os.Looper.loop(Looper.java:123) 04-12 18:54:45.216:
    E/AndroidRuntime(275):    at
    android.app.ActivityThread.main(ActivityThread.java:4627) 04-12
    18:54:45.216: E/AndroidRuntime(275):  at
    java.lang.reflect.Method.invokeNative(Native Method) 04-12
    18:54:45.216: E/AndroidRuntime(275):  at
    java.lang.reflect.Method.invoke(Method.java:521) 04-12 18:54:45.216:
    E/AndroidRuntime(275):    at
    com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:868)
    04-12 18:54:45.216: E/AndroidRuntime(275):    at
    com.android.internal.os.ZygoteInit.main(ZygoteInit.java:626) 04-12
    18:54:45.216: E/AndroidRuntime(275):  at
    dalvik.system.NativeStart.main(Native Method) 04-12 18:54:45.216:
    E/AndroidRuntime(275): Caused by: java.lang.NullPointerException 04-12
    18:54:45.216: E/AndroidRuntime(275):  at
    id.nuhun.lbssekolah.DatabaseHelper.getAllKamus(DatabaseHelper.java:58)
    04-12 18:54:45.216: E/AndroidRuntime(275):    at
    id.nuhun.lbssekolah.MainActivity.setData(MainActivity.java:47) 04-12
    18:54:45.216: E/AndroidRuntime(275):  at
    id.nuhun.lbssekolah.MainActivity.onCreate(MainActivity.java:39) 04-12
    18:54:45.216: E/AndroidRuntime(275):  at
    android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1047)
    04-12 18:54:45.216: E/AndroidRuntime(275):    at
    android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2627)
    04-12 18:54:45.216: E/AndroidRuntime(275):    ... 11 more </p>
  </blockquote>