Load a file from external storage to Inputstream Load a file from external storage to Inputstream android android

Load a file from external storage to Inputstream


Try

File file = new File(Uri.toString());FileInputStream fileInputStream = new FileInputStream(file);

Then you can read from the stream.


String fileName = "OfflineMap/maps.xml";String path = Environment.getExternalStorageDirectory()+"/"+fileName;File file = new File(path);FileInputStream fileInputStream = new FileInputStream(file);


Here is a working code, you can InputStream with a storage file:

       File sdcard = Environment.getExternalStorageDirectory();       File file = new File(sdcard,"Demo.xml");       InputStream fileInputStream = new FileInputStream(file);