title: How can I set image view which stored in file system according to path in database?
body: <p>I have three questions:</p>
  <ol>
  <li><p>If I choose to store <code>image.png</code> in file system where should I store it <code>res/drawable/image_1.png</code>  or <code>res/drawable/images/image_1.png</code></p>
  </li>
  <li><p>And I'm going to store path of image in database. What should I put in <code>image_path</code> field ex. <code>image_1</code> or <code>images/image_1</code> or etc.</p>
  </li>
  <li><p>How can I get path of image from database and set image to view follow my code in the bottom? Could you guys change it for me?</p>
  </li>
  </ol>
  <h2>I already have answer</h2>
  <ol>
  <li>in case storing image file in file system in <code>assets/images/pic_1.png</code></li>
  <li>In database, &quot;image_path field&quot; , you will put <code>images/pic_1.png</code> in it.</li>
  <li>To get and set image: according to Trim's answer.</li>
  </ol>
  <p>AND I have fixed the following code according to Trim's answer.</p>
  <p>Thanks so much</p>
  <p><strong>placeListActivity.class</strong></p>
  <pre><code>public class placeListActivity extends ListActivity {
     
      private static MyDB mDbHelper;
      String[] from = new String[] { Constants.COL_TITLE};
      int[] to = new int[] {R.id.list_place_title};
      private Cursor c;
  
      
      @Override
      public void onCreate(Bundle savedInstanceState) {
          super.onCreate(savedInstanceState);
          
          
          mDbHelper = new MyDB(this);
          mDbHelper.createDatabase();
          mDbHelper.open();
          c = mDbHelper.getAllPlaces();
  
          
          setListAdapter(new SimpleCursorAdapter(this, 
                    R.layout.list_place, c, 
                    from, to));
          
          final ListView lv = getListView();
            
          
          lv.setOnItemClickListener(new OnItemClickListener() {
              public void onItemClick(AdapterView&lt;?&gt; parent, View view,int position, long id) {
  
                  Intent i = new Intent(view.getContext(), Place.class);    
                  i.putExtra(Constants.KEY_ID, id);
                  i.putExtra(Constants.COL_TITLE, c.getString(
                          c.getColumnIndexOrThrow(Constants.COL_TITLE)));
                  i.putExtra(Constants.COL_CONTENT, c.getString(
                          c.getColumnIndexOrThrow(Constants.COL_CONTENT)));
   
                  i.putExtra(Constants.COL_IMAGE, c.getString(
                          c.getColumnIndexOrThrow(Constants.COL_IMAGE)));
                  
                  
                  
                  startActivity(i);
              
              }
            });
          
          
      }
  
  }
  </code></pre>
  <p><strong>Place.class</strong></p>
  <pre><code>public class Place extends Activity {
      
      private TextView title;
      private TextView content;
      private ImageView placeImage;
  
      public void onCreate(Bundle savedInstanceState) {
          super.onCreate(savedInstanceState);
  
          this.setContentView(R.layout.detail_place);
          
          title = (TextView) findViewById(R.id.place_title);
          content = (TextView) findViewById(R.id.place_content);
  
          placeImage = (ImageView) findViewById(R.id.place_image);
          
          Bundle extras = getIntent().getExtras();
          if (extras != null) {
          // reference XML defined views that we will touch in code
          String stringTitle = extras.getString(Constants.COL_TITLE);
          String stringContent = extras.getString(Constants.COL_CONTENT);
  
          String imageID = extras.getString(Constants.COL_IMAGE);
          
   
          if (title != null) {
              title.setText(stringTitle); 
          }
          if (content != null) {
              content.setText(stringContent);
          }
  
          /*if (placeImage != null) {
              placeImage.setImageDrawable(Drawable.createFromPath(imageID));
          }*/
          
          if (placeImage != null) {
          
          try {
              InputStream path = getAssets().open(imagePath);
              Bitmap bit = BitmapFactory.decodeStream(path);
              placeImage.setImageBitmap(bit);
          } catch (IOException e) {
              // TODO Auto-generated catch block
              e.printStackTrace();
          }
              }
          }
      }
  }
  </code></pre>