Android: 如何从内部存储中读取 html 文件并在 webview 中加载

Android: how to read html files from internal storage and load in webview

我搜索了很多,但没有解决我的问题。我想构建一个从选项卡的内部文件夹读取 html 文件的应用程序。 html 个文件的路径是 /file manager/device storage/Android/data/K1.html.
问题是网页的数量可能会因用户而增加或减少,我想构建应用程序可以读取该文件夹中所有网页的功能。我使用以下代码从内部存储读取文件,但它没有指向路径。我知道这并不难,请指导我如何获得此功能,在此先感谢。

File tabFolder = getFilesDir();
String root = tabFolder.toString();
File myFile = new File(root + "/Android/data/K1.html");
    if(myFile.exists()){
    Toast.makeText(MainActivity.this, "exists", Toast.LENGTH_SHORT).show();

    }
    else{
        Toast.makeText(MainActivity.this, "does not exists", Toast.LENGTH_SHORT).show();
    } 

立即尝试...

String fileName = "K1.html";
String content = "K1 html file content here";
FileOutputStream outputStream = null;
try {
outputStream = openFileOutput(fileName, Context.MODE_PRIVATE);
outputStream.write(content.getBytes());
outputStream.close();
} catch (Exception e) {
e.printStackTrace();}

String path=getApplicationContext().getFilesDir().getAbsolutePath()+"/K1.html";
File file = new File ( path ); 
if ( file.exists() ) 
{
 // Toast File is exists
}
else
{
 // Toast File is not exists
}