Calling a file path from the android workspace folder

前端 未结 3 994
说谎
说谎 2021-01-23 14:16

Basically I have right clicked on my project name and successfully created a new folder called pdfs. I want to pre load some pdf files in here so how would I call this path/some

3条回答
  •  天涯浪人
    2021-01-23 15:06

    Its better to place them in assets/ folder, that way you will be able to access them with AssetManager. Something like this

        AssetManager assetManager = getAssets();
    
        InputStream in = null;
        OutputStream out = null;
        File file = new File(getFilesDir(), "name_of_pdf_file.pdf");
        try
        {
            in = assetManager.open("name_of_pdf_file.pdf");
    
            in.close();
            in = null;
        } catch (Exception e)
        {
            Log.e("tag", e.getMessage());
        }
    

提交回复
热议问题