IllegalArgumentException: column '_data' does not exist

前端 未结 4 1438
死守一世寂寞
死守一世寂寞 2020-12-13 19:25

In Nougat, this function is not working.

String path = getRealPathFromURI(this, getIntent().getParcelableExtra(Intent.EXTRA_STREAM));


4条回答
  •  佛祖请我去吃肉
    2020-12-13 19:51

    This function is working properly in devices before Android N

    It works for very few Uri values, may not have a result (e.g., for things that are indexed by MediaStore that are not local files), and may not have a usable result (e.g., for files on removable storage).

    So please help.

    Use a ContentResolver and openInputStream() to get an InputStream on the content identified by the Uri. Ideally, just use that stream directly, for whatever it is that you are trying to do. Or, use that InputStream and some FileOutputStream on a file that you control to make a copy of the content, then use that file.

提交回复
热议问题