I wonder is it possible to update the image path and image in the folder ?
I've been successfully stored the image path and text into MySQL from android, and save the image in a directory.
Php for upload image
<?php
    if( $_SERVER['REQUEST_METHOD']=='POST' ){
        if( !empty( $_POST['listItems'] ) ){
            $listItems = json_decode( $_POST['listItems'], true ); 
            $mysqli = new mysqli("127.0.0.1:3307", "root", "", "androiddb");
            if( $mysqli->connect_errno ) echo "Failed to connect to MySQL";
            $sql="INSERT INTO `staff_benefit` 
                 ( `type`, `amount`, `description`, `image`, `ts_id` ) 
                  VALUES ( ?, ?, ?, ?, ? )";
            if($stmt=$mysqli->prepare($sql )){
                $url="http://192.168.1.7:80/Android/CRUD/PhotoUpload/";
                foreach( $listItems as $item ){ 
                    $id = uniqid();
                    $image_name = $id.".png";
                    $save_path = 'PhotoUpload/'.$image_name;
                    $image_url = $url.$image_name;
                    $bytes=file_put_contents($save_path, base64_decode($item['image']));
                    if( !$bytes ){
                        echo 'Error saving image';  
                    }else{
                        $stmt->bind_param('sssss', 
                        $item['type'], 
                        $item['amount'], 
                        $item['description'], 
                        $image_url, 
                        $item['ts_id'] );
                        if( !$res=$stmt->execute()){ 
                            echo 'Query failed with code: '.$stmt->errno;
                        }
                    }
                } 
            }
            $mysqli->close();
        }
    }
?>
In Edit_Staff_Benefit_ListView, the two row data will be retrieved and loaded into listView. When list get clicked, it will intent to Edit_Staff for edit.
Edit_Staff_Benefit_ListView
 listViewEdit.setOnItemClickListener(new AdapterView.OnItemClickListener() {
            @Override
            public void onItemClick(AdapterView<?> listView, View view,
                                    int position, long id) {
                mClickedPosition = position; // update
                long i1d = staffs.get(position).getId();
                Intent intent = new Intent(getActivity(), Edit_Staff.class);
                intent.putExtra("id", i1d);
                intent.putExtra("ID", ID);  // this is ts_id
                intent.putExtra("mClickedPosition", mClickedPosition);
                startActivityForResult(intent, PROJECT_REQUEST_CODE);
            }
        });
Edit_Staff
  mClickedPosition=getIntent().getIntExtra("mClickedPosition",-1);
            ID = getIntent().getLongExtra("id", 0);
            IDFromInfo=getIntent().getStringExtra("ID");
            Toast.makeText(getApplicationContext(), "ID" + ID+"FK"+IDFromInfo , Toast.LENGTH_LONG).show();
            if (getIntent().getExtras() != null) {
                RetrieveDetails(ID);  // retrieve all the data based on position in listView
            }
  save.setOnClickListener(new View.OnClickListener() {     // if save button clicked
            @Override
            public void onClick(View v) {
                Intent returnIntent = new Intent();
                claimType = spinnerType.getSelectedItem().toString();
                Description = description.getText().toString();
                Amount = amount.getText().toString();
                if(mClickedPosition==-1)
                {
                 //Add(claimType,Amount,Description,photo);
                }
                else
                {
                    update(claimType,Amount,Description,photo);
                }
            }
        });
update function
 public void update( final String claimType,  final String Amount, final String Description, final Uri photo)
    {
           class updateImageAndText extends AsyncTask<Void,Void,String>{
               ProgressDialog loading;
               @Override
               protected void onPreExecute() {
                   super.onPreExecute();
                   loading = ProgressDialog.show(Edit_Staff.this,"Updating...","Wait...",false,false);
               }
               @Override
               protected void onPostExecute(String s) {
                   super.onPostExecute(s);
                   loading.dismiss();
                   Toast.makeText(getApplicationContext(), s, Toast.LENGTH_LONG).show();
                   try {
                       Intent returnIntent = new Intent();
                       returnIntent.putExtra("ClaimType", claimType);
                       returnIntent.putExtra("Amount", Amount);
                       returnIntent.putExtra("Description", Description);
                       returnIntent.putExtra("photo", photo);
                       setResult(Activity.RESULT_OK, returnIntent);
                       finish();
                   }catch(Exception e)
                   {
                   }
               }
               @Override
               protected String doInBackground(Void... params) {
                   HashMap<String,String> hashMap = new HashMap<>();
                   hashMap.put(Configs.KEY_ID,String.valueOf(ID));
                   hashMap.put(Configs.KEY_TYPE,claimType);
                   hashMap.put(Configs.KEY_AMOUNT,Amount);
                   hashMap.put(Configs.KEY_DESCRIPTION,Description);
                   hashMap.put(Configs.KEY_IMAGE,photo.toString());
                   RequestHandler rh = new RequestHandler();
                   String s = rh.sendPostRequest(Configs.URL_UPDATEDE_IMAGE_TEXT,hashMap);
                   return s;
               }
           }
Update.php
<?php 
    if($_SERVER['REQUEST_METHOD']=='POST'){
        //Getting values 
        $id = $_POST['id'];
        $type = $_POST['type'];
        $amount = $_POST['amount'];
        $description = $_POST['description'];
        $image = $_POST['image'];
        //importing database connection script 
        require_once('dbConnect.php');
        $sql = "UPDATE staff_benefit 
                  SET type = '$type', amount = '$amount', description='description', image='image' 
                WHERE id = '$id'";
        //Updating database table 
        if(mysqli_query($con,$sql)){
            echo ' Updated Successfully';
        }else{
            echo mysqli_error($con);
            exit;
        }
        //closing connection 
        mysqli_close($con);
    }
?>
App crashed when save button is clicked.Is it because I'm wrote a wrong update. php ? Thanks
LogCat
01-16 19:36:51.373  22786-22786/com.example.project.myapplication E/WindowManager﹕ android.view.WindowLeaked: Activity com.example.project.myapplication.GUI.Edit_Staff has leaked window com.android.internal.policy.impl.PhoneWindow$DecorView{42c71d80 V.E..... R......D 0,0-684,324} that was originally added here
            at android.view.ViewRootImpl.<init>(ViewRootImpl.java:467)
            at android.view.WindowManagerGlobal.addView(WindowManagerGlobal.java:267)
            at android.view.WindowManagerImpl.addView(WindowManagerImpl.java:69)
            at android.app.Dialog.show(Dialog.java:289)
            at android.app.ProgressDialog.show(ProgressDialog.java:116)
            at android.app.ProgressDialog.show(ProgressDialog.java:104)
            at com.example.project.myapplication.GUI.Edit_Staff$1updateImageAndText.onPreExecute(Edit_Staff.java:154)
            at android.os.AsyncTask.executeOnExecutor(AsyncTask.java:587)
            at android.os.AsyncTask.execute(AsyncTask.java:535)
            at com.example.project.myapplication.GUI.Edit_Staff.update(Edit_Staff.java:191)
            at com.example.project.myapplication.GUI.Edit_Staff$1.onClick(Edit_Staff.java:103)
