I am trying to access an XML file on a username and password protected Sharpoint website from an Android app. Using:
URL url = new URL(“http://username:password@thewebsite.com/file/test.xml);
URLConnection ucon = url.openConnection();
InputStream is = ucon.getInputStream();
BufferedInputStream bis = new BufferedInputStream(is);
ByteArrayBuffer baf = new ByteArrayBuffer(50);
results in a file not found exception. If I turn the username/password requirement off on the website it works, but it does not find the file when I change it to require username and password.
Downloading a file like this is not going to work, because you aren’t authenticated to SharePoint (the error it throws is not actually an FileNotFoundException but most likely an AccessDenied Exception – you will have to look up the SharePoint ULS Log in the 14/LOGS folder).
I’m not a android dev (neither java) but i guess the best way to do this is to use the SharePoint web services, especially the Copy Web Service. You’ll have to generate a client proxy class from the web service’s .wsdl file, and then you can call it via code.
Someone here tried to achieve something similar (only uploading instead of downloading) so this should give you a good head-start with your solution. Also here is a piece of code which you might need – it’s in C# but you should be able to translate it to Java.
Hope this helps