には外部のjarを使用しており、通常のクラスに加えてhtmlファイルがあります。私の最後のAPKのルートディレクトリを意味APK内のファイルを読み取る
この
- assests
- 解像度
- のAndroidManifest.xml
- classes.dex
- resources.arsc
- helloworld.htmlようになります
私のアプリケーションから最後のファイルにアクセスするには "helloworld.html"?
には外部のjarを使用しており、通常のクラスに加えてhtmlファイルがあります。私の最後のAPKのルートディレクトリを意味APK内のファイルを読み取る
この
私のアプリケーションから最後のファイルにアクセスするには "helloworld.html"?
Androidパッケージ階層は、Javaアプリケーションパッケージと似ていません。 このようなファイルにはアクセスできません。
あなたのアプリケーションではhelloworld.htmlファイルを使用する必要があります。
だから
getAssets()
を使用してファイルを取得/asset
ディレクトリにし、あなたのアクティビティコードでこのファイルを置きます。 jarファイルの代わりにライブラリプロジェクトをしていないのはなぜfile:///android_asset/helloworld.html
これは私が望むものではありません。私は開発者に瓶を与えています。私はそれらに瓶を使用してもらいたいと言いません - "さらに、このhtmlファイルを資産ディレクトリに入れてください" – Omer
私の答えはあなたの質問に関連しています.. "私のアプリケーションから最後のファイル "helloworld.html"へのアクセス? " – user370305
申し訳ありませんが、わかりませんでした。 htmlファイルはassetsディレクトリにありません – Omer
:
ものようなファイルにアクセスしますか?あなたはあなたのファイルで「assets/SecureManifest.xml
を」文字列を置換する必要が
「helloworld.html
」
public static InputStream getInputStreamFromApkResource(String apkFilePath, String apkResPath) throws IOException {
JarFile jarFile = new JarFile(apkFilePath);
JarEntry jarEntry = jarFile.getJarEntry(apkResPath);
return jarFile.getInputStream(jarEntry);
}
// Example usage reading the file "SecureManifest.xml" under "assets" folder:
File sdcard = Environment.getExternalStorageDirectory();
File apkFile = new File(sdcard, "file.apk");
if (apkFile.exists()) {
try {
InputStream is =getInputStreamFromApkResource(apkFile.toString(), "assets/SecureManifest.xml");
BufferedReader br = new BufferedReader(new InputStreamReader(is));
String str;
while ((str = br.readLine()) != null) {
Log.d("***", str);
}
} catch (IOException e) {
e.printStackTrace();
}
}
githubのの要旨はhere
を見つけることができますが、あなたは資産内のHTMLファイルを保存し、「getAssets(呼び出すことができます) "? – goodm