I've tried the answers on every other post out there and they all seem to return 0.0 as the file size of my image which cannot be true. I think the file path is what's causing it to return the incorrect file size. Here is my code:
@Override
protected void onActivityResult(int requestCode, int resultCode, @Nullable Intent data) {
super.onActivityResult(requestCode, resultCode, data);
if (requestCode == PICK_IMAGE_REQUEST && resultCode == RESULT_OK && data != null && data.getData() != null) {
imageUri = data.getData();
textViewImageAttachmentStatus.setText("File has been attached");
textViewImageAttachmentStatus.setTextColor(Color.parseColor("#008577"));
Picasso.get().load(imageUri).into(imageViewPreviewImage);
String imagePath = imageUri.getPath();
File imageFile = new File(imagePath);
long imageSize = imageFile.length() / 1024;
System.out.println(imageSize);
}
}