title: How To Save and Retrieve path image in SQLite android
body: <p>i want to save and retrieve image path in my application</p>
  
  <p>this is my DBhelper</p>
  
  <pre><code>public void insert(String kdstore,String nama, String alamat, String kodepos, String notel, 
          String lng, String lat ,String Perus,String gambar){
  
      //waktu = new Date().toString();
      ContentValues cv = new ContentValues();
      cv.put("kdstore", kdstore);
      cv.put("nama", nama);
      cv.put("alamat", alamat);
      cv.put("kodepos", kodepos);
      cv.put("notel", notel);
      cv.put("lng", lng);
      cv.put("lat", lat);
      cv.put("Perus", Perus);
      cv.put("gambar", df.fileName);
      System.out.println();
      getWritableDatabase().insert("alfamapp", "name", cv);
  }
  </code></pre>
  
  <p>and this is my startCameraActivity</p>
  
  <pre><code>_path=Environment.getExternalStorageDirectory().getPath() + "/DCIM/Camera/";
          fileName =  String.format(System.currentTimeMillis()+".jpg");
          File file = new File(_path, fileName);
          try {
          file.createNewFile();
          } catch (IOException e) {
          e.printStackTrace();
          }
          Uri outputFileUri = Uri.fromFile(file);
          Intent intent = new Intent(android.provider.MediaStore.ACTION_IMAGE_CAPTURE);
          intent.putExtra(MediaStore.EXTRA_OUTPUT, outputFileUri);
  
          startActivityForResult(intent, IMAGE_CAPTURE); 
  </code></pre>
  
  <p>how can i save path from cameraActivity in my database??
  please help me :)</p>
  
  <hr>
  
  <p>i put code to inserting on startCamera method,,this code like this</p>
  
  <pre><code>public void startCamera() 
  {
      Cursor c = helper.getById(almagId);
      c.moveToFirst();
  
      file = new File(_path, fileName);
      try {
      file.createNewFile();
      } catch (IOException e) {
      e.printStackTrace();
      }    
  
      file1 = new File(_path, fileName);
      try {
      file1.createNewFile();
      } catch (IOException e) {
      e.printStackTrace();
      }
  
      Uri outputFileUri = Uri.fromFile(file);
      Intent intent = new Intent(android.provider.MediaStore.ACTION_IMAGE_CAPTURE);
      intent.putExtra(MediaStore.EXTRA_OUTPUT, outputFileUri);
      finishActivity(IMAGE_CAPTURE);
  
      Uri outputFileUri1 = Uri.fromFile(file1);
      intent.putExtra(MediaStore.EXTRA_OUTPUT, outputFileUri1);
      startActivityForResult(intent, IMAGE_CAPTURE);
      System.out.println(file1);
  
      Dbhelper helper = new Dbhelper(this);
      SQLiteDatabase db = helper.getWritableDatabase();
      db.execSQL("update alfamapp set gambar ='"+file+"',gambar1 ='"+file1+"' " +
                  "where kdstore='"+helper.getKdStore(c)+"'");
      db.execSQL("insert into image (kdstore,image1) values ('"+helper.getKdStore(c)+"','"+file+"')");
      db.execSQL("update image set image2 ='"+file1+"' where kdstore='"+helper.getKdStore(c)+"'");
      db.close();
      helper.close();
      load();
  
      System.out.println(db);
  
  }
  </code></pre>
  
  <p>and then this code to retrieve  this image</p>
  
  <pre><code>if(helper.getGamb(c).equals("")){
          System.out.println("gamb kosong");
          detGam.setImageResource(R.drawable.gambarnf);
  
      }else detGam.setImageDrawable(Drawable.createFromPath(helper.getGamb(c)));
  </code></pre>
  
  <p>you have solution to my code??thank you very much :)</p>