0

I am trying to access file from device. All works goods but when i browse and select file from google drive it gives null path. I have seen many question but didn't got the answer. One solution which i got below only gives me the file name.

  public static String getGDriveDataColumn(Context context, Uri uri, String selection,
                                         String[] selectionArgs) {
    Cursor cursor = null;
    final String column = "_display_name";
    final String[] projection = {
            column
    };

    try {
        cursor = context.getContentResolver().query(uri, projection, selection, selectionArgs, null);
        if (cursor != null && cursor.moveToFirst()) {
            final int column_index = cursor.getColumnIndexOrThrow(column);
            return cursor.getString(column_index);
        }
    } finally {
        if (cursor != null)
            cursor.close();
    }

    return null;

}

Is it possible to get that file? Because that file is on the drive and not on the device. Please help me how can i get that file.

FaisalAhmed
  • 3,469
  • 7
  • 46
  • 76

0 Answers0