How to transfer a txt data file to my Android app

  • Replies:0
  • OpenNot stickiedUnanswered
  • Forum posts: 2

Oct 8, 2014, 2:39:28 PM via Website

Sorry, I stupidly wrote my post in french. Re-writing it in English.

I must transfer a data file necessary for my app.
I read many threads on the subject and I stll don't understand how it works.

  1. I'm using android studio 0.8.6. A lot of threads mentions the folder assets which apparently resides in src/main. When I create a new project the folder doesn't exist. I create manually one and I put in it jpg and txt files.

  2. I run the following code:
    AssetManager am = getAssets();
    String[] files = new String[0];
    try {
    files = am.list("Files";);
    } catch (IOException e) {
    for(int i=0;i<files.length;i++){
    Toast.makeText(getApplicationContext(), "File: "+files[i]+" ", Toast.LENGTH_SHORT).show();

And I get a files.length = 0

  1. I can create files, write in it and read it but I don know where they reside.

And that's not what I want to do. I want to pass the data with the app.

Sorry for the long email but I'm lost.
Thanks in advance!

Recommended by NextPit