1. Are you ready for the Galaxy S20? Here is everything we know so far!

How to use a local file to test a program

Discussion in 'Android Development' started by HeavensSentSword, Jan 26, 2016.

  1. HeavensSentSword

    HeavensSentSword Well-Known Member
    Thread Starter

    Hello, I was wondering how to use a local file (i.e. something off you local disk drive C:) for testing purposes. I am working on understanding the URLConnection thing in android and want to try to bring a txt file in for processing, but I don't know how to because C: is not a valid html code. I also do not want to place the text file into the actual program because that would defeat the purpose of calling it in via URL.
    Do I have to make a File file new File thing and read the outside file into that to do this?
    thank you very much

     


    Member1764000 likes this.
  2. Best Answer:
    Post #3 by Member1764000, Jan 30, 2016 (3 points)

    1. Download the Forums for Android™ app!


      Download

       
  3. Deleted User

    Deleted User Guest

    squintbox and HeavensSentSword like this.
  4. Hi HeavensSentSword, If your purpose is to make an http call to get a file, it can be done by setting up a local website on your pc (you can use a program like XAMPP)

    Once you create the local website, you can place the txt file under the web folder; to call it from your browser you should write "localhost/txtfile.txt" for example.
    To call it form your app you must use the IP Address of your pc that has the local website on.
    Example your pc has the IP 192.168.1.100 and you placed the file in the root folder of the website, the url that must be called from the app will be http:192.168.1.100/name_of_file.txt

    I have tried and it worked for me with no issues.
    I created a local web site on my pc, then made a test app in which I called the txt file using the url written before.

    Hope you understand what I wrote, my english is not so good.
     
    HeavensSentSword likes this.
Loading...
Similar Threads - local file test
  1. RedHeadDev
    Replies:
    4
    Views:
    963
  2. karthikdkd11
    Replies:
    1
    Views:
    623
  3. netgoogle
    Replies:
    2
    Views:
    1,054
  4. shmn
    Replies:
    11
    Views:
    1,523
  5. mutie
    Replies:
    2
    Views:
    882
  6. Spec_tech
    Replies:
    8
    Views:
    1,660
  7. shakushinnen
    Replies:
    4
    Views:
    603
  8. TheOneGuy
    Replies:
    0
    Views:
    854
  9. timelinex
    Replies:
    13
    Views:
    1,036
  10. Keramidas
    Replies:
    0
    Views:
    1,300

Share This Page

Loading...