3

In my project I have to make a text file and read 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?

2 Answers 2

2

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) {}
         }
}
Sign up to request clarification or add additional context in comments.

Comments

0

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.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.