title: How to get a path of image (URI) and send it to database?
body: <p>I have a code to get an image if I click the button, in my problem, I wanna get the URI/path of the image and send it into the database, after that I wanna show it in ImageView. And this is my code.</p>
  
  <pre><code>       @Override
  public void onActivityResult(int req, int res, Intent imageIntent) {
      super.onActivityResult(req, res, imageIntent);
  
      switch (req) {
          case SELECT_ICON:
              if (res == RESULT_OK) {
                  try {
                      final Uri iconUri = imageIntent.getData();
                      final String imgUri = iconUri.toString();
                      final InputStream iconStream = getContentResolver().openInputStream(iconUri);
                      final Bitmap selectedIcon = BitmapFactory.decodeStream(iconStream);
                      imageView.setImageBitmap(selectedIcon);
  
                      saveButton.setOnClickListener(new View.OnClickListener() {
                          @Override
                          public void onClick(View arg0) {
                              String tname = text1.getText().toString();
                              String date = textView.getText().toString();
                              String priority = spinner1.getSelectedItem().toString();
                              String notes = text2.getText().toString();
                              String path = imgUri;
  
                              dbHelper.addTask(new Task(tname, date, priority, notes, path));
                              Toast.makeText(getApplicationContext(), "Success!!!", Toast.LENGTH_LONG).show();
                              TaskListActivity.tasklist.RefreshList();
                              finish();
                          }
                      });
                  } catch (FileNotFoundException err) {
                      err.printStackTrace();
                  }
              }
      }
  }
  </code></pre>