0

i've send my image from another activity to the final activity, and when i upload the image to activity there's none of them in the storage. when i upload to firebase it's a success but it turn out the data is empty

The database look like this

and i using this method to upload the image to firebase

lanjut.setOnClickListener (new View.OnClickListener ( ) {
            @Override
            public void onClick(View v) {

                DatabaseCicilan6 databaseCicilan6 = new DatabaseCicilan6 (pendapatanperbulan, kategoripekerjaan, tempatkerja, jabatankerja,
                        alamatkerja, lamabekerja, alamatnow, kotanow, kecamatannow, kelurahannow,
                        rtnow, rwnow, alamatktp, kotaktp, kecamatanktp, kelurahanktp, rtktp, rwktp,
                        nohp, hubungan, namakontak, nohp2, hubungan2, namakontak2, Payment1, Payment2,
                        Payment3, Payment4, Payment5, Payment6, imageUri, imageUri2, imageUri3, tenor6, cicilan6,
                        tipebarang, hargabarang, dphp, fullName, nik, phoneNumber, date, currentDateandTime,
                        currentDate, tanggalpengajuan);

                DatabaseCicilan9 databaseCicilan9 = new DatabaseCicilan9 (pendapatanperbulan, kategoripekerjaan, tempatkerja, jabatankerja,
                        alamatkerja, lamabekerja, alamatnow, kotanow, kecamatannow, kelurahannow,
                        rtnow, rwnow, alamatktp, kotaktp, kecamatanktp, kelurahanktp, rtktp, rwktp,
                        nohp, hubungan, namakontak, nohp2, hubungan2, namakontak2, Payment1, Payment2,
                        Payment3, Payment4, Payment5, Payment6, Payment7, Payment8, Payment9, imageUri,
                        imageUri2, imageUri3, tenor9, cicilan9, tipebarang, hargabarang, dphp, fullName,
                        nik, phoneNumber, date, currentDateandTime, currentDate, tanggalpengajuan);

                

                if (getIntent ( ).hasExtra ("tenor6")) {
                    reference.child ("Pending").child (currentDateandTime).setValue (databaseCicilan6);
                } else {
                    reference.child ("Pending").child (currentDateandTime).setValue (databaseCicilan9);
                }
                startActivity (new Intent (getApplicationContext ( ), PengajuanBerhasil.class));
            }
        });
    }

and this is how i send the image from the the other activity

 intent.putExtra("imageUri", (imageUri).toString ());
                    startActivity(intent);
  @Override
    protected void onActivityResult(int requestCode, int resultCode, @Nullable Intent data) {
        super.onActivityResult (requestCode, resultCode, data);
        if(requestCode == 100) {
            Bitmap bitmap = (Bitmap) data.getExtras ( ).get ("data");
            ByteArrayOutputStream bytes = new ByteArrayOutputStream ( );
            bitmap.compress (Bitmap.CompressFormat.JPEG, 0, bytes);
            String path = MediaStore.Images.Media.insertImage (getApplicationContext ( ).getContentResolver ( ), bitmap, String.valueOf (UUID.randomUUID()), null);
            imageUri = Uri.parse (path);
            imageView.setImageURI (imageUri);
        }
    }

i hope someone can help me with this problem

  • What exactly is empty? – Alex Mamo Dec 20 '21 at 10:10
  • well, there's a text inside of the firebase database that look like the picture that i send with the question. inside of the imageUri was `"content://media/external/images/media/9863"`, im trying to get the image and save it to storage and after that put the link inside o my realtime database –  Dec 20 '21 at 10:45
  • Here is an [answer](https://stackoverflow.com/questions/53299915/how-to-get-offline-uploaded-file-download-url-in-firebase/) that can help you a achieve that. – Alex Mamo Dec 20 '21 at 11:05
  • @AlexMamo i need to upload the image that i have, but they upload the path instead of the image url, eh wait nvm –  Dec 20 '21 at 11:45
  • Yes, upload the image first to the storage and the n save the URL in the database. These are the correct steps, right? – Alex Mamo Dec 20 '21 at 12:00
  • @AlexMamo ya it is but, i a bit confuse how to took the image using the storageRef, i did this ` UploadTask uploadTask = storage.putBytes(imageUri);`but the putBytes say can't resolve method –  Dec 20 '21 at 14:04
  • Have you added the correct dependencies or added the right imports? – Alex Mamo Dec 21 '21 at 12:59

0 Answers0