Removed some unused classes
[pub/Android/ownCloud.git] / src / com / owncloud / android / files / services / FileOperation.java
1 /* ownCloud Android client application
2 * Copyright (C) 2012 Bartek Przybylski
3 * Copyright (C) 2012-2013 ownCloud Inc.
4 *
5 * This program is free software: you can redistribute it and/or modify
6 * it under the terms of the GNU General Public License as published by
7 * the Free Software Foundation, either version 3 of the License, or
8 * (at your option) any later version.
9 *
10 * This program is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU General Public License for more details.
14 *
15 * You should have received a copy of the GNU General Public License
16 * along with this program. If not, see <http://www.gnu.org/licenses/>.
17 *
18 */
19 package com.owncloud.android.files.services;
20
21 import java.io.File;
22
23 import com.owncloud.android.AccountUtils;
24 import com.owncloud.android.datamodel.OCFile;
25 import com.owncloud.android.network.OwnCloudClientUtils;
26
27 import android.accounts.Account;
28 import android.content.Context;
29 import eu.alefzero.webdav.WebdavClient;
30
31 public class FileOperation {
32
33 Context mContext;
34
35 public FileOperation(Context contex){
36 this.mContext = contex;
37 }
38
39 /**
40 * Deletes a file from ownCloud - locally and remote.
41 * @param file The file to delete
42 * @return True on success, otherwise false
43 */
44 public boolean delete(OCFile file){
45
46 Account account = AccountUtils.getCurrentOwnCloudAccount(mContext);
47 WebdavClient client = OwnCloudClientUtils.createOwnCloudClient(account, mContext);
48 if(client.deleteFile(file.getRemotePath())){
49 File localFile = new File(file.getStoragePath());
50 return localFile.delete();
51 }
52
53 return false;
54 }
55
56 }