android - DownloadManager COLUMN_LOCAL_FILENAME deprecated -


on android n, getting exception. known issue per documentation, asks me use contentresolver.openfiledescriptor()

https://developer.android.com/reference/android/app/downloadmanager.html#column_local_filename

i not sure how use. contentresolver object here can use filename? never used it. so, appreciate help.

08-04 11:20:59.765 7010 7290 w system.err: java.lang.securityexception: column_local_filename deprecated; use contentresolver.openfiledescriptor() instead

08-04 11:20:59.765 7010 7290 w system.err: @ android.app.downloadmanager$cursortranslator.getstring(downloadmanager.java:1499)

here code.

    downloadmanager.query query = new downloadmanager.query();     query.setfilterbyid(id);     cursor cursor = downloadmanager.query(query);      final string downloadfilepath = cursor.getstring(cursor.getcolumnindex(downloadmanager.column_local_filename));     cursor.close(); 

i tried downlaodmanager.getfileuri, isn't looking for. appreciate help.

thanks

the following working me now:

    string downloadfilepath = null;     string downloadfilelocaluri = cursor.getstring(cursor.getcolumnindex(downloadmanager.column_local_uri));     if (downloadfilelocaluri != null) {         file mfile = new file(uri.parse(downloadfilelocaluri).getpath());         downloadfilepath = mfile.getabsolutepath();     } 

Comments