简体   繁体   中英

How to set up webdav on Android Studio?

I am trying to start developing some advanced android applications for learning purposes. I wanted to implement WebDAV to be able to push files from my device to an FTP server. I have the FTP set up and I went through the documentation of Sardine-Android. But not able to understand how to import any of the various versions available. If anyone can point out what needs to be done for that, it would be helpful. Just for testing I did create a Sardine-Android project and imported https://github.com/yeonsh/Sardine-Android but that on building the project in Android Studio it cannot find "org.simpleframework.xml.Element" I am totally new to this so it might be something trivial that I am asking but any kind of help would be appreciated. Thanks

After research, I was able to do it via following steps:

Get the package de.aflx.sardine from the git repository Sardine-Android mentioned above. Place it in your project's java folder.

Get the following libraries and import it as module to your project: simple-xml-2.7.1, stax-1.2.0, stax-api-1.0.1, xpp3-1.1.3.3

Add simple-xml-2.7.1 as module "implementation" (new Gradle change from "dependencies")

Sardine Implementation:

Then using Sardine class create an object and initialize it with SardineFactory, eg Sardine sardine = SardineFactory.begin(username, password);

Then send data to server using sardine.put() eg sardine.put(url_to_server+filename,data_to_send);

Thought this would help others trying to do similar thing.

This is how Gradle Build will look like:

dependencies {
    implementation 'com.android.support.constraint:constraint-layout:1.0.2'
    implementation 'com.android.support:design:25.4.0'
    implementation fileTree(include: ['*.jar'], dir: 'libs')
    implementation 'com.android.support:appcompat-v7:25.3.1'
    implementation 'commons-net:commons-net:3.6'
    implementation project(':simple-xml-2.7.1')
}

This is how the project structure will look like

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM