在我的应用程序中,我用来DownloadManager从 Firebase 下载文件。
import static android.os.Environment.DIRECTORY_DOWNLOADS;
public class Physics extends AppCompatActivity {
PDFView pdfView;
FirebaseStorage firebaseStorage;
StorageReference storageReference;
StorageReference ref;
File file;
File files;
ProgressBar progressBar;
private Context context;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
getWindow().setFlags(WindowManager.LayoutParams.FLAG_SECURE, WindowManager.LayoutParams.FLAG_SECURE);
setContentView(R.layout.activity_physics1);
pdfView = findViewById(R.id.pdfview);
progressBar = (ProgressBar) findViewById(R.id.progressBar);
Context mContext = getApplicationContext();
String path = mContext.getFilesDir().getAbsolutePath() + "/storage/emulated/0/Android/data/com.impwala.impwala/files/Download/asd.nomedia";
File file = new File("/storage/emulated/0/Android/data/com.impwala.impwala/files/Download/asd.nomedia");
if (file.exists()) {
files = new File("/storage/emulated/0/Android/data/com.impwala.impwala/files/Download/asd.nomedia");
pdfView.fromFile(files).load();
} else {
if (haveNetwork()) {
download();
} else …Run Code Online (Sandbox Code Playgroud)