Well guys, I started working with firebase storage, I was able to send and receive firebase data normally using the documentation.
But I would like the photo that the user sent and received was kept even without internet access, does anyone know how to do it?
Fragment that receives the image
mStorageRef = FirebaseStorage.getInstance().getReference();
//imagens instancia
imageView = (ImageView) view.findViewById(R.id.imageView4);
btn_imagem = (ImageButton) view.findViewById(R.id.imageButton);
btn_imagem.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
Intent i = new Intent(Intent.ACTION_PICK);
i.setType("image/*");
startActivityForResult(i,GALERIA);
}
});
@Override
public void onActivityResult(int requestCode, int resultCode, Intent data) {
super.onActivityResult(requestCode, resultCode, data);
if(requestCode == GALERIA && resultCode == RESULT_OK){
progressDialog.setMax(100);
progressDialog.setTitle("Upload de imagem");
progressDialog.setMessage("Salvando...");
progressDialog.show();
Uri uri = data.getData();
StorageReference filepatch = mStorageRef.child("Fotos").child(uri.getLastPathSegment());
filepatch.putFile(uri).addOnSuccessListener(new OnSuccessListener<UploadTask.TaskSnapshot>() {
@Override
public void onSuccess(UploadTask.TaskSnapshot taskSnapshot) {
progressDialog.dismiss();
Uri imagemRecebida = taskSnapshot.getDownloadUrl();
Picasso.with(getActivity()).load(imagemRecebida).fit().centerCrop().into(imageView);
Toast.makeText(getActivity(), "Upload realizado com sucesso!!!",Toast.LENGTH_SHORT).show();
}
});
}
}
}