private void getDir(String dirPath) {
    reports = new ArrayList<ReportData>();

    File f = new File(dirPath);
    File[] files = f.listFiles();

    // order files so most recent are nearest the top
    Arrays.sort(
        files,
        new Comparator<File>() {
          public int compare(File f1, File f2) {
            return Long.valueOf(f2.lastModified()).compareTo(f1.lastModified());
          }
        });

    for (int i = 0; i < files.length; i++) {
      File file = files[i];
      if (!file.isHidden()
          && !file.isDirectory()
          && db.getReportText(file.getAbsolutePath()) != null)
        reports.add(db.getReportDataFromThumb(file.getAbsolutePath()));
    }

    ReportDataAdapter adapter = new ReportDataAdapter(this, R.layout.row, reports);

    ListView listView = getListView();
    listView.setAdapter(adapter);

    listView.setOnItemLongClickListener(
        new OnItemLongClickListener() {
          @Override
          public boolean onItemLongClick(
              AdapterView<?> parent, View view, final int position, long id) {

            new AlertDialog.Builder(ReportHistoryActivity.this)
                .setTitle("Confirm Delete")
                .setMessage("Delete this report?")
                .setIcon(android.R.drawable.ic_dialog_alert)
                .setPositiveButton(
                    android.R.string.yes,
                    new DialogInterface.OnClickListener() {
                      public void onClick(DialogInterface dialog, int whichButton) {
                        DatabaseService db = new DatabaseService(getBaseContext());
                        db.deleteReport(reports.get(position).getImageUri().getPath());
                        Intent intent = new Intent();
                        intent.setClassName(
                            ServiceServer.getAndroidContext(),
                            "com.timetravellingtreasurechest.gui.ReportHistoryActivity");
                        intent.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
                        startActivity(intent);
                      }
                    })
                .setNegativeButton(android.R.string.no, null)
                .show();

            return true;
          }
        });
  }
  protected void onListItemClick(ListView l, View v, int position, long id) {
    File file = new File(reports.get(position).getImageUri().getPath());

    MainActivity.latestReport =
        db.getReportDataFromThumb(reports.get(position).getThumbUri().getPath());
    Intent intent = new Intent();
    intent.setClassName(this, "com.timetravellingtreasurechest.gui.ManageReportActivity");
    intent.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
    startActivity(intent);
  }