private void fillData(Uri uri) {
    String[] projection = {
      SchemeFeedbackContract.Feedback.COLUMN_FEEDBACK,
      SchemeFeedbackContract.Feedback.COLUMN_OTHER_SCHEME,
      SchemeFeedbackContract.Feedback.COLUMN_SCHEME_ID
    };
    Cursor cursor = getContentResolver().query(uri, projection, null, null, null);
    if (cursor != null) {
      cursor.moveToFirst();
      Long schemeId =
          cursor.getLong(
              cursor.getColumnIndexOrThrow(SchemeFeedbackContract.Feedback.COLUMN_SCHEME_ID));

      for (int i = 0; i < schemeSpinner.getCount(); i++) {

        Long s = schemeSpinner.getItemIdAtPosition(i);
        if (s == schemeId) {
          schemeSpinner.setSelection(i);
        }
      }

      otherSchemeText.setText(
          cursor.getString(
              cursor.getColumnIndexOrThrow(SchemeFeedbackContract.Feedback.COLUMN_OTHER_SCHEME)));
      feedbackText.setText(
          cursor.getString(
              cursor.getColumnIndexOrThrow(SchemeFeedbackContract.Feedback.COLUMN_FEEDBACK)));

      // always close the cursor
      cursor.close();
    }
  }
 private static void setSpinnerItemById(Spinner spinner, long id) {
   for (int n = 0, l = spinner.getCount(); n < l; ++n)
     if (spinner.getItemIdAtPosition(n) == id) {
       spinner.setSelection(n);
       return;
     }
 }
  /**
   * Seleciona um item no combo considerando o id ZERO
   *
   * @author Anderson Cabral
   * @date 01/02/2013
   * @param spinner
   * @param id
   */
  public static void selecionarItemCombo(Spinner spinner, long id) {

    for (int i = 0; i < spinner.getCount(); i++) {
      long itemIdAtPosition2 = spinner.getItemIdAtPosition(i);
      if (itemIdAtPosition2 == id) {
        spinner.setSelection(i);
        break;
      }
    }
  }
  private void setLastDeckSpinnerPosition() {
    // TODO Auto-generated method stub

    for (int i = 0; i < mDecks.getCount(); i++) {
      long itemIdAtPosition2 = mDecks.getItemIdAtPosition(i);
      if (itemIdAtPosition2 == DatabaseHelper.LAST_SELECTED_DECK) {
        mDecks.setSelection(i);
        break;
      }
    }
  }
  @Override
  protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);

    this.setContentView(R.layout.poi);

    if (mPoiManager == null) mPoiManager = new PoiManager(this);
    mCf = new CoordFormatter(this);

    mTitle = (EditText) findViewById(R.id.Title);
    mLat = (EditText) findViewById(R.id.Lat);
    mLon = (EditText) findViewById(R.id.Lon);
    mAlt = (EditText) findViewById(R.id.Alt);
    mDescr = (EditText) findViewById(R.id.Descr);
    mHidden = (CheckBox) findViewById(R.id.Hidden);

    mLat.setHint(mCf.getHint());
    mLat.setOnFocusChangeListener(
        new View.OnFocusChangeListener() {
          @Override
          public void onFocusChange(View v, boolean hasFocus) {
            if (!hasFocus) {
              try {
                mLat.setText(
                    mCf.convertLat(CoordFormatter.convertTrowable(mLat.getText().toString())));
              } catch (Exception e) {
                mLat.setText("");
              }
            }
          }
        });

    mLon.setHint(mCf.getHint());
    mLon.setOnFocusChangeListener(
        new View.OnFocusChangeListener() {
          @Override
          public void onFocusChange(View v, boolean hasFocus) {
            if (!hasFocus) {
              try {
                mLon.setText(
                    mCf.convertLon(CoordFormatter.convertTrowable(mLon.getText().toString())));
              } catch (Exception e) {
                mLon.setText("");
              }
            }
          }
        });

    mSpinner = (Spinner) findViewById(R.id.spinnerCategory);
    Cursor c = mPoiManager.getGeoDatabase().getPoiCategoryListCursor();
    startManagingCursor(c);
    SimpleCursorAdapter adapter =
        new SimpleCursorAdapter(
            this,
            R.layout.poicategory_spinner, // android.R.layout.simple_spinner_item,
            c,
            new String[] {"name", "iconid"},
            new int[] {android.R.id.text1, R.id.pic});
    adapter.setDropDownViewResource(R.layout.poicategory_spinner_dropdown);
    mSpinner.setAdapter(adapter);

    Bundle extras = getIntent().getExtras();
    if (extras == null) extras = new Bundle();
    int id = extras.getInt("pointid", PoiPoint.EMPTY_ID());

    if (id < 0) {
      mPoiPoint = new PoiPoint();
      mTitle.setText(extras.getString("title"));
      mSpinner.setSelection(0);
      mLat.setText(mCf.convertLat(extras.getDouble("lat")));
      mLon.setText(mCf.convertLon(extras.getDouble("lon")));
      mAlt.setText(String.format(Locale.UK, "%.1f", extras.getDouble("alt", 0.0)));
      mDescr.setText(extras.getString("descr"));
      mHidden.setChecked(false);
    } else {
      mPoiPoint = mPoiManager.getPoiPoint(id);

      if (mPoiPoint == null) finish();

      mTitle.setText(mPoiPoint.Title);
      for (int pos = 0; pos < mSpinner.getCount(); pos++) {
        if (mSpinner.getItemIdAtPosition(pos) == mPoiPoint.CategoryId) {
          mSpinner.setSelection(pos);
          break;
        }
      }
      mLat.setText(mCf.convertLat(mPoiPoint.GeoPoint.getLatitude()));
      mLon.setText(mCf.convertLon(mPoiPoint.GeoPoint.getLongitude()));
      mAlt.setText(String.format(Locale.UK, "%.1f", mPoiPoint.Alt));
      mDescr.setText(mPoiPoint.Descr);
      mHidden.setChecked(mPoiPoint.Hidden);
    }

    ((Button) findViewById(R.id.saveButton))
        .setOnClickListener(
            new OnClickListener() {
              public void onClick(View v) {
                doSaveAction();
              }
            });
    ((Button) findViewById(R.id.discardButton))
        .setOnClickListener(
            new OnClickListener() {
              public void onClick(View v) {
                PoiActivity.this.finish();
              }
            });
  }