2

How do i open a file with QFile with link in android -content://com.android.providers.downloads.documents/document/raw.pdf

I tried below code but its showing that the file not open

 QString path("content://com.android.providers.downloads.documents/document/raw.pdf");
 QUrl path_url(path);
 path = path_url.toLocalFile();
 QFile* file = new QFile(path);
 file->open(QIODevice::ReadOnly)
Husni Abdul Nazer
  • 103
  • 1
  • 1
  • 12

1 Answers1

0

QQmlFile could format it to /storage/emulated/0/....

QString path("content://com.android.providers.downloads.documents/document/raw.pdf"); QUrl url(path);

QFile file(QQmlFile::urlToLocalFileOrQrc(url));
  if (!file.open(QFile::ReadOnly)) {
    emit error(tr("Could not open file. '%1'").arg(file.errorString()));
    return;
  } 

example for detail implementation.

Ashif
  • 1,652
  • 14
  • 30