开发者

where is internal file stored in an android project?

In my project I have to make a text file and r开发者_如何学Pythonead particulars from that file. I need to know where I should place the file in directory so that I can successfully read it in my java code?


That should go in /assets/

Read this tutorial also about Android Beginners: Intro to Resources and Assets

AssetManager assetManager = getAssets();
InputStream stream = null;
try {
    stream = assetManager.open("file.txt");
} catch (IOException e) {
    // handle
}
finally {
         if (stream != null) {
               try {
                   stream.close();
              } catch (IOException e) {}
         }
}


If they are files that your app downloads or creates, you should follow the guidelines for using internal storage or external storage, if it is included in the apk, then the file should go in /assets/ and you can access it using the AssetManager.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜