Farzan Najipour
Farzan Najipour

Reputation: 2493

Android - pick file

I'm trying to pick file with this extension : doc & pdf

I've already used this to pick Image and Video:

public void pickImage()
{
    Intent pickImageIntent = new Intent(Intent.ACTION_PICK,
        android.provider.MediaStore.Images.Media.EXTERNAL_CONTENT_URI);

    startActivityForResult(pickImageIntent, PICK_IMAGE_ACTIVITY_REQUEST_CODE);
}

public void pickVideo()
{
    Intent pickVideoIntent = new Intent(Intent.ACTION_PICK,
        android.provider.MediaStore.Video.Media.EXTERNAL_CONTENT_URI);

    startActivityForResult(pickVideoIntent, PICK_VIDEO_ACTIVITY_REQUEST_CODE);
}

I want something like that for files. I've read this and use it in my code

public void pickFile()
{
    Intent pickFileIntent = new Intent(Intent.ACTION_GET_CONTENT);
    pickFileIntent.setType("file/*");
    startActivityForResult(pickFileIntent, PICKFILE_RESULT_CODE);
}

Actually it gives me an error in last line: startActivityForResult(pickFileIntent, PICKFILE_RESULT_CODE);

error: cannot find symbol

How to fix it?

Upvotes: 1

Views: 235

Answers (1)

Gaurav Jindal
Gaurav Jindal

Reputation: 227

You have defined the variable "PICKFILE_RESULT_CODE" and others right?

Upvotes: 1

Related Questions