-1

I am working on an android application where I want users to upload a file and I want to read the contents of uploaded file and display it . I have been reading files from SD card but I now I need the user to upload a file . I searched a lot but I didn't get any solution for it.

My code for reading the file from SD card

   File file = new File(dir, "/tounzip/b.txt");
   FileInputStream fileInputStream = null;
    try {
        fileInputStream = new FileInputStream(file);
    } catch (FileNotFoundException e) {
        e.printStackTrace();
    }
    DataInputStream input = new DataInputStream(fileInputStream);

Its reading the file contents successfully but Is there any way to make the user upload the file and read the contents from it ? Any help would be great !! Thanks !!

Anusha
  • 939
  • 3
  • 13
  • 31

1 Answers1

1

Android file chooser

You require a file picker/file chooser.

Logic is you read the stream and save the stream in your app sandbox (app's memory i.e. /data/package..) then do whatever you want from there.

If file size is small then even a in-memory implementation will help.

Community
  • 1
  • 1
takrishna
  • 4,884
  • 3
  • 18
  • 35