When i choose a PDF file from my device's folders, I keep getting a null reference no matter the path I set it to, I have no idea what is causing this null reference so I need help. I referred to this to pick the PDF file from the device, but it does not show how to send to the server.
The following is my code.
public void btnOtherFilesOnClick(View v){
int PDF = 1;
Intent i = new Intent();
i.setType("application/pdf");
i.setAction(Intent.ACTION_GET_CONTENT);
startActivityForResult(Intent.createChooser(i, "Select Pdf"), PDF);
btnNo = 6;
}
else if (btnNo == 6 ) {
// File downloads = new File(String.valueOf(Environment.getExternalStorageState()));
//create new file directory object
//File downloads = new File(Environment.getExternalStoragePublicDirectory(Environment.DIRECTORY_DOWNLOADS).getAbsolutePath());
Uri selectedImage = data.getData();
String[] filePathColumn = {MediaStore.Files.FileColumns.DATA};
Cursor cursor = getContentResolver().query(selectedImage, filePathColumn, null, null, null);
cursor.moveToFirst();
int columnIndex = cursor.getColumnIndex(filePathColumn[0]);
cursor.close();
picturePath = cursor.getString(columnIndex);
file = new File(picturePath);
copyDatabaseToSD();
createServerPDFStorage();
my picturePath keeps being null even though my filePathColumn[0]
is not. I'm trying to send the PDF to SQLite server.