4

I have this code :

 public static final int RESULT_OK = -1;
@Override
public void onActivityResult(int requestCode, int resultCode, Intent data) {
    switch (requestCode) {
        case FILE_SELECT_CODE:
            if (resultCode == RESULT_OK) {
                // Get the Uri of the selected file
                Uri fileUri = data.getData();
                File F = new File(fileUri.getPath());
                Log.d("File", "File Uri: " + fileUri.toString());                 
                Intent intent = new Intent(getContext(),activity_file_sharing.class);
                intent.putExtra("Filepath", fileUri.toString());
                startActivity(intent);
            }
            break;
    }
    super.onActivityResult(requestCode, resultCode, data);
}

F.length() always return 0 i need to path the size of the selected file to the other activity

can anyone help

Sora
  • 2,465
  • 18
  • 73
  • 146

1 Answers1

1

Please, check this link:

how do I get file size of temp file in android?

Try this:

File file = new File(selectedPath);
int file_size = Integer.parseInt(String.valueOf(file.length()/1024));
Community
  • 1
  • 1
Amg91
  • 165
  • 8
  • 25