cv.put(ProviderTableMeta.FILE_LAST_SYNC_DATE, file.getLastSyncDateForProperties());
cv.put(ProviderTableMeta.FILE_LAST_SYNC_DATE_FOR_DATA, file.getLastSyncDateForData());
cv.put(ProviderTableMeta.FILE_KEEP_IN_SYNC, file.keepInSync() ? 1 : 0);
+ cv.put(ProviderTableMeta.FILE_ETAG, file.getEtag());
boolean sameRemotePath = fileExists(file.getRemotePath());
boolean changesSizeOfAncestors = false;
cv.put(ProviderTableMeta.FILE_LAST_SYNC_DATE, file.getLastSyncDateForProperties());
cv.put(ProviderTableMeta.FILE_LAST_SYNC_DATE_FOR_DATA, file.getLastSyncDateForData());
cv.put(ProviderTableMeta.FILE_KEEP_IN_SYNC, file.keepInSync() ? 1 : 0);
+ cv.put(ProviderTableMeta.FILE_ETAG, file.getEtag());
if (fileExists(file.getRemotePath())) {
OCFile oldFile = getFileByPath(file.getRemotePath());
getColumnIndex(ProviderTableMeta.FILE_LAST_SYNC_DATE_FOR_DATA)));
file.setKeepInSync(c.getInt(
c.getColumnIndex(ProviderTableMeta.FILE_KEEP_IN_SYNC)) == 1 ? true : false);
+ file.setEtag(c.getString(c.getColumnIndex(ProviderTableMeta.FILE_ETAG)));
+
}
return file;
}
private String mEtag;
+
/**
* Create new {@link OCFile} with given path.
*
mKeepInSync = source.readInt() == 1;
mLastSyncDateForProperties = source.readLong();
mLastSyncDateForData = source.readLong();
+ mEtag = source.readString();
}
@Override
dest.writeInt(mKeepInSync ? 1 : 0);
dest.writeLong(mLastSyncDateForProperties);
dest.writeLong(mLastSyncDateForData);
+ dest.writeString(mEtag);
}
/**
mLastSyncDateForData = 0;
mKeepInSync = false;
mNeedsUpdating = false;
+ mEtag = null;
}
/**
@Override
public String toString() {
- String asString = "[id=%s, name=%s, mime=%s, downloaded=%s, local=%s, remote=%s, parentId=%s, keepInSinc=%s]";
- asString = String.format(asString, Long.valueOf(mId), getFileName(), mMimeType, isDown(), mLocalPath, mRemotePath, Long.valueOf(mParentId), Boolean.valueOf(mKeepInSync));
+ String asString = "[id=%s, name=%s, mime=%s, downloaded=%s, local=%s, remote=%s, parentId=%s, keepInSinc=%s etag=%]";
+ asString = String.format(asString, Long.valueOf(mId), getFileName(), mMimeType, isDown(), mLocalPath, mRemotePath, Long.valueOf(mParentId), Boolean.valueOf(mKeepInSync), mEtag);
return asString;
}
return mEtag;
}
+ public void setEtag(String etag) {
+ this.mEtag = etag;
+ }
+
public long getLocalModificationTimestamp() {
if (mLocalPath != null && mLocalPath.length() > 0) {
File f = new File(mLocalPath);
public static final String AUTHORITY_FILES = "org.owncloud";\r
public static final String DB_FILE = "owncloud.db";\r
public static final String DB_NAME = "filelist";\r
- public static final int DB_VERSION = 4;\r
+ public static final int DB_VERSION = 5;\r
\r
private ProviderMeta() {\r
}\r
public static final String FILE_LAST_SYNC_DATE = "last_sync_date"; // _for_properties, but let's keep it as it is\r
public static final String FILE_LAST_SYNC_DATE_FOR_DATA = "last_sync_date_for_data";\r
public static final String FILE_KEEP_IN_SYNC = "keep_in_sync";\r
+ public static final String FILE_ETAG = "etag";\r
\r
public static final String DEFAULT_SORT_ORDER = FILE_NAME\r
+ " collate nocase asc";\r
OK,
OK_SSL,
OK_NO_SSL,
+ OK_NO_CHANGES_ON_DIR,
UNHANDLED_HTTP_CODE,
UNAUTHORIZED,
FILE_NOT_FOUND,
public RemoteOperationResult(ResultCode code) {
mCode = code;
- mSuccess = (code == ResultCode.OK || code == ResultCode.OK_SSL || code == ResultCode.OK_NO_SSL);
+ mSuccess = (code == ResultCode.OK || code == ResultCode.OK_SSL || code == ResultCode.OK_NO_SSL || code == ResultCode.OK_NO_CHANGES_ON_DIR);
}
private RemoteOperationResult(boolean success, int httpCode) {
file.setFileLength(we.contentLength());
file.setMimetype(we.contentType());
file.setModificationTimestamp(we.modifiedTimestamp());
+ file.setEtag(we.etag());
+
return file;
}
import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStream;
+import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.Vector;
-import org.apache.commons.httpclient.Header;
import org.apache.http.HttpStatus;
import org.apache.jackrabbit.webdav.MultiStatus;
import org.apache.jackrabbit.webdav.client.methods.PropFindMethod;
import android.accounts.Account;
import android.content.Context;
-
import com.owncloud.android.Log_OC;
import com.owncloud.android.datamodel.DataStorageManager;
import com.owncloud.android.datamodel.OCFile;
/** Id of the folder to synchronize in the local database */
private long mParentId;
-
+
/** Access to the local database */
private DataStorageManager mStorageManager;
return mChildren;
}
-
+ public String getRemotePath() {
+ return mRemotePath;
+ }
+
+ public long getParentId() {
+ return mParentId;
+ }
+
@Override
protected RemoteOperationResult run(WebdavClient client) {
RemoteOperationResult result = null;
mFailsInFavouritesFound = 0;
mConflictsFound = 0;
mForgottenLocalFiles.clear();
-
+ boolean fileChanged = false;
+ boolean dirChanged = true;
+
// code before in FileSyncAdapter.fetchData
PropFindMethod query = null;
try {
Log_OC.d(TAG, "Synchronizing " + mAccount.name + ", fetching files in " + mRemotePath);
-
+
// remote request
query = new PropFindMethod(client.getBaseUri() + WebdavUtils.encodePath(mRemotePath));
int status = client.executeMethod(query);
-
+
// check and process response - /// TODO take into account all the possible status per child-resource
if (isMultiStatus(status)) {
MultiStatus resp = query.getResponseBodyAsMultiStatus();
-
+
// synchronize properties of the parent folder, if necessary
if (mParentId == DataStorageManager.ROOT_PARENT_ID) {
+ dirChanged = false;
+ WebdavEntry we = new WebdavEntry(resp.getResponses()[0], client.getBaseUri().getPath());
+
+ // Properties of server folder
+ OCFile parent = fillOCFile(we);
+ // Properties of local folder
+ OCFile localParent = mStorageManager.getFileById(1);
+ if (localParent == null || !(parent.getEtag().equalsIgnoreCase(localParent.getEtag()))) {
+ mStorageManager.saveFile(parent);
+ mParentId = parent.getFileId();
+ dirChanged = true;
+ }
+ }
+ else if (! mRemotePath.equalsIgnoreCase(OCFile.PATH_SEPARATOR)){
+ dirChanged = false;
WebdavEntry we = new WebdavEntry(resp.getResponses()[0], client.getBaseUri().getPath());
+
+ // Properties of server folder
OCFile parent = fillOCFile(we);
- mStorageManager.saveFile(parent);
- mParentId = parent.getFileId();
+ // Properties of local folder
+ OCFile localParent = mStorageManager.getFileByPath(mRemotePath);
+ if (localParent == null || !(parent.getEtag().equalsIgnoreCase(localParent.getEtag()))) {
+ dirChanged = true;
+ }
}
-
+
+ if (dirChanged) {
// read contents in folder
+ List<String> filesOnServer = new ArrayList<String> (); // Contains the lists of files on server
List<OCFile> updatedFiles = new Vector<OCFile>(resp.getResponses().length - 1);
List<SynchronizeFileOperation> filesToSyncContents = new Vector<SynchronizeFileOperation>();
for (int i = 1; i < resp.getResponses().length; ++i) {
/// new OCFile instance with the data from the server
WebdavEntry we = new WebdavEntry(resp.getResponses()[i], client.getBaseUri().getPath());
OCFile file = fillOCFile(we);
-
+
+ filesOnServer.add(file.getRemotePath()); // Registry the file in the list
+
/// set data about local state, keeping unchanged former data if existing
file.setLastSyncDateForProperties(mCurrentSyncTime);
OCFile oldFile = mStorageManager.getFileByPath(file.getRemotePath());
+
+ // Check if it is needed to synchronize the folder
+ fileChanged = false;
if (oldFile != null) {
- file.setKeepInSync(oldFile.keepInSync());
- file.setLastSyncDateForData(oldFile.getLastSyncDateForData());
- file.setModificationTimestampAtLastSyncForData(oldFile.getModificationTimestampAtLastSyncForData()); // must be kept unchanged when the file contents are not updated
- checkAndFixForeignStoragePath(oldFile);
- file.setStoragePath(oldFile.getStoragePath());
- }
+ if (!file.getEtag().equalsIgnoreCase(oldFile.getEtag())) {
+ fileChanged = true;
+ }
+ } else
+ fileChanged= true;
- /// scan default location if local copy of file is not linked in OCFile instance
- if (file.getStoragePath() == null && !file.isDirectory()) {
- File f = new File(FileStorageUtils.getDefaultSavePathFor(mAccount.name, file));
- if (f.exists()) {
- file.setStoragePath(f.getAbsolutePath());
- file.setLastSyncDateForData(f.lastModified());
+ if (fileChanged){
+ if (file.isDirectory())
+ file.setEtag("");
+ if (oldFile != null) {
+ file.setKeepInSync(oldFile.keepInSync());
+ file.setLastSyncDateForData(oldFile.getLastSyncDateForData());
+ file.setModificationTimestampAtLastSyncForData(oldFile.getModificationTimestampAtLastSyncForData()); // must be kept unchanged when the file contents are not updated
+ checkAndFixForeignStoragePath(oldFile);
+ file.setStoragePath(oldFile.getStoragePath());
}
+ /// scan default location if local copy of file is not linked in OCFile instance
+ if (file.getStoragePath() == null && !file.isDirectory()) {
+ File f = new File(FileStorageUtils.getDefaultSavePathFor(mAccount.name, file));
+ if (f.exists()) {
+ file.setStoragePath(f.getAbsolutePath());
+ file.setLastSyncDateForData(f.lastModified());
+ }
+ }
+
+ /// prepare content synchronization for kept-in-sync files
+ if (file.keepInSync()) {
+ SynchronizeFileOperation operation = new SynchronizeFileOperation( oldFile,
+ file,
+ mStorageManager,
+ mAccount,
+ true,
+ false,
+ mContext
+ );
+ filesToSyncContents.add(operation);
+ }
+
+ updatedFiles.add(file);
}
-
- /// prepare content synchronization for kept-in-sync files
- if (file.keepInSync()) {
- SynchronizeFileOperation operation = new SynchronizeFileOperation( oldFile,
- file,
- mStorageManager,
- mAccount,
- true,
- false,
- mContext
- );
- filesToSyncContents.add(operation);
- }
-
- updatedFiles.add(file);
}
-
+
// save updated contents in local database; all at once, trying to get a best performance in database update (not a big deal, indeed)
mStorageManager.saveFiles(updatedFiles);
-
+
// request for the synchronization of files AFTER saving last properties
- SynchronizeFileOperation op = null;
RemoteOperationResult contentsResult = null;
- for (int i=0; i < filesToSyncContents.size(); i++) {
- op = filesToSyncContents.get(i);
+ for (SynchronizeFileOperation op: filesToSyncContents) {//int i=0; i < filesToSyncContents.size(); i++) {
contentsResult = op.execute(client); // returns without waiting for upload or download finishes
if (!contentsResult.isSuccess()) {
if (contentsResult.getCode() == ResultCode.SYNC_CONFLICT) {
} // won't let these fails break the synchronization process
}
-
+
// removal of obsolete files
mChildren = mStorageManager.getDirectoryContent(mStorageManager.getFileById(mParentId));
- OCFile file;
+ //OCFile file;
String currentSavePath = FileStorageUtils.getSavePath(mAccount.name);
- for (int i=0; i < mChildren.size(); ) {
- file = mChildren.get(i);
- if (file.getLastSyncDateForProperties() != mCurrentSyncTime) {
- Log_OC.d(TAG, "removing file: " + file);
- mStorageManager.removeFile(file, (file.isDown() && file.getStoragePath().startsWith(currentSavePath)));
- mChildren.remove(i);
- } else {
- i++;
+ for (OCFile fileChild: mChildren) {
+ if (!filesOnServer.contains(fileChild.getRemotePath())) {
+ Log_OC.d(TAG, "removing file: " + fileChild.getFileName());
+ mStorageManager.removeFile(fileChild, (fileChild.isDown() && fileChild.getStoragePath().startsWith(currentSavePath)));
+ // mChildren.remove(fileChild); //.remove(i);
}
}
-
+
} else {
client.exhaustResponse(query.getResponseBodyAsStream());
}
+ }
// prepare result object
- if (isMultiStatus(status)) {
+ if (!dirChanged) {
+ result = new RemoteOperationResult(ResultCode.OK_NO_CHANGES_ON_DIR);
+ mChildren = mStorageManager.getDirectoryContent(mStorageManager.getFileById(mParentId));
+
+ } else if (isMultiStatus(status)) {
if (mConflictsFound > 0 || mFailsInFavouritesFound > 0) {
result = new RemoteOperationResult(ResultCode.SYNC_CONFLICT); // should be different result, but will do the job
-
+
} else {
result = new RemoteOperationResult(true, status, query.getResponseHeaders());
}
} else {
result = new RemoteOperationResult(false, status, query.getResponseHeaders());
}
-
-
-
+ Log_OC.i(TAG, "Synchronizing " + mAccount.name + ", folder " + mRemotePath + ": " + result.getLogMessage());
+
} catch (Exception e) {
result = new RemoteOperationResult(e);
}
}
}
-
+
return result;
}
-
+
public boolean isMultiStatus(int status) {
return (status == HttpStatus.SC_MULTI_STATUS);
file.setMimetype(we.contentType());
file.setModificationTimestamp(we.modifiedTimestamp());
file.setParentId(mParentId);
+ file.setEtag(we.etag());
return file;
}
*
* If the copy fails, the link to the local file is nullified. The account of forgotten files is kept in
* {@link #mForgottenLocalFiles}
- *
+ *)
* @param file File to check and fix.
*/
private void checkAndFixForeignStoragePath(OCFile file) {
ProviderTableMeta.FILE_KEEP_IN_SYNC);
mProjectionMap.put(ProviderTableMeta.FILE_ACCOUNT_OWNER,
ProviderTableMeta.FILE_ACCOUNT_OWNER);
+ mProjectionMap.put(ProviderTableMeta.FILE_ETAG,
+ ProviderTableMeta.FILE_ETAG);
}
private static final int SINGLE_FILE = 1;
+ ProviderTableMeta.FILE_LAST_SYNC_DATE + " INTEGER, "
+ ProviderTableMeta.FILE_KEEP_IN_SYNC + " INTEGER, "
+ ProviderTableMeta.FILE_LAST_SYNC_DATE_FOR_DATA + " INTEGER, "
- + ProviderTableMeta.FILE_MODIFIED_AT_LAST_SYNC_FOR_DATA + " INTEGER );"
+ + ProviderTableMeta.FILE_MODIFIED_AT_LAST_SYNC_FOR_DATA + " INTEGER, "
+ + ProviderTableMeta.FILE_ETAG + " TEXT );"
);
}
}
if (!upgraded)
Log_OC.i("SQL", "OUT of the ADD in onUpgrade; oldVersion == " + oldVersion + ", newVersion == " + newVersion);
+
+ if (oldVersion < 5 && newVersion >= 5) {
+ Log_OC.i("SQL", "Entering in the #4 ADD in onUpgrade");
+ db.beginTransaction();
+ try {
+ db .execSQL("ALTER TABLE " + ProviderTableMeta.DB_NAME +
+ " ADD COLUMN " + ProviderTableMeta.FILE_ETAG + " TEXT " +
+ " DEFAULT NULL");
+
+ upgraded = true;
+ db.setTransactionSuccessful();
+ } finally {
+ db.endTransaction();
+ }
+ }
+ if (!upgraded)
+ Log_OC.i("SQL", "OUT of the ADD in onUpgrade; oldVersion == " + oldVersion + ", newVersion == " + newVersion);
}
-
}
}
package com.owncloud.android.ui.activity;
import java.io.File;
+import java.io.IOException;
import android.accounts.Account;
+import android.accounts.AuthenticatorException;
+import android.accounts.OperationCanceledException;
import android.app.AlertDialog;
import android.app.ProgressDialog;
import android.app.Dialog;
import com.owncloud.android.Log_OC;
import com.owncloud.android.R;
import com.owncloud.android.authentication.AccountAuthenticator;
+import com.owncloud.android.authentication.AccountUtils;
+import com.owncloud.android.authentication.AccountUtils.AccountNotFoundException;
import com.owncloud.android.datamodel.DataStorageManager;
import com.owncloud.android.datamodel.FileDataStorageManager;
import com.owncloud.android.datamodel.OCFile;
import com.owncloud.android.files.services.FileObserverService;
import com.owncloud.android.files.services.FileUploader;
import com.owncloud.android.files.services.FileUploader.FileUploaderBinder;
+import com.owncloud.android.network.OwnCloudClientUtils;
import com.owncloud.android.operations.CreateFolderOperation;
import com.owncloud.android.operations.OnRemoteOperationListener;
import com.owncloud.android.operations.RemoteOperation;
import com.owncloud.android.operations.RemoveFileOperation;
import com.owncloud.android.operations.RenameFileOperation;
import com.owncloud.android.operations.SynchronizeFileOperation;
+import com.owncloud.android.operations.SynchronizeFolderOperation;
import com.owncloud.android.operations.RemoteOperationResult.ResultCode;
import com.owncloud.android.syncadapter.FileSyncService;
import com.owncloud.android.ui.dialog.EditNameDialog;
import com.owncloud.android.ui.preview.PreviewMediaFragment;
import com.owncloud.android.ui.preview.PreviewVideoActivity;
+import eu.alefzero.webdav.WebdavClient;
+
/**
* Displays, what files the user has available in his ownCloud.
*
FileFragment second = getSecondFragment();
OCFile currentDir = getCurrentDir();
if((currentDir != null && currentDir.getParentId() != 0) ||
- (second != null && second.getFile() != null)) {
+ (second != null && second.getFile() != null)) {
onBackPressed();
+
}
break;
}
public void onBrowsedDownTo(OCFile directory) {
pushDirname(directory);
cleanSecondFragment();
+
+ // Sync Folder
+ startSyncFolderOperation(directory.getRemotePath(), directory.getFileId());
+// // Update folder size on DB
+// getStorageManager().calculateFolderSize(directory.getParentId());
+
}
/**
} else if (operation instanceof CreateFolderOperation) {
onCreateFolderOperationFinish((CreateFolderOperation)operation, result);
+
+ } else if (operation instanceof SynchronizeFolderOperation) {
+ onSynchronizeFolderOperationFinish((SynchronizeFolderOperation)operation, result);
+ }
+ }
+
+
+ /**
+ * Updates the view associated to the activity after the finish of an operation trying to synchronize a folder.
+ *
+ * @param operation Synchronize operation performed.
+ * @param result Result of the synchronization.
+ */
+ private void onSynchronizeFolderOperationFinish(SynchronizeFolderOperation operation, RemoteOperationResult result) {
+
+ OCFileListFragment list = getListOfFilesFragment();
+ enableDisableViewGroup(list.getListView(), true);
+
+ setSupportProgressBarIndeterminateVisibility(false);
+ if (result.isSuccess()) {
+ if (result.getCode() != ResultCode.OK_NO_CHANGES_ON_DIR) {
+ DataStorageManager storageManager = getStorageManager();
+ OCFile parentDir = storageManager.getFileByPath(operation.getRemotePath());
+
+ // Update folder size on DB
+ getStorageManager().calculateFolderSize(parentDir.getFileId());
+
+ // Refrest List
+ refreshListOfFilesFragment(parentDir);
+ }
+ } else {
+ try {
+ Toast msg = Toast.makeText(FileDisplayActivity.this, R.string.sync_file_fail_msg, Toast.LENGTH_LONG);
+ msg.show();
+
+ } catch (NotFoundException e) {
+ Log_OC.e(TAG, "Error while trying to show fail message " , e);
+ }
+ }
+ }
+
+
+ private void refreshListOfFilesFragment(OCFile parentDir) {
+ OCFileListFragment fileListFragment = getListOfFilesFragment();
+ if (fileListFragment != null) {
+ fileListFragment.listDirectory(parentDir);
}
}
}
return null;
}
+
+ public void startSyncFolderOperation(String remotePath, long parentId) {
+ long currentSyncTime = System.currentTimeMillis();
+
+ OCFileListFragment list = getListOfFilesFragment();
+ enableDisableViewGroup(list.getListView(), false);
+
+ // perform folder synchronization
+ RemoteOperation synchFolderOp = new SynchronizeFolderOperation( remotePath,
+ currentSyncTime,
+ parentId,
+ getStorageManager(),
+ getAccount(),
+ getApplicationContext()
+ );
+ synchFolderOp.execute(getAccount(), this, this, mHandler, this);
+
+ setSupportProgressBarIndeterminateVisibility(true);
+ }
+
+ public void enableDisableViewGroup(ViewGroup viewGroup, boolean enabled) {
+ int childCount = viewGroup.getChildCount();
+ for (int i = 0; i < childCount; i++) {
+ View view = viewGroup.getChildAt(i);
+ view.setEnabled(enabled);
+ view.setClickable(!enabled);
+ if (view instanceof ViewGroup) {
+ enableDisableViewGroup((ViewGroup) view, enabled);
+ }
+ }
+ }
}
import com.owncloud.android.files.services.FileUploader.FileUploaderBinder;
import com.owncloud.android.operations.OnRemoteOperationListener;
import com.owncloud.android.operations.RemoteOperation;
+import com.owncloud.android.operations.RemoteOperationResult;
import com.owncloud.android.operations.RemoveFileOperation;
import com.owncloud.android.operations.RenameFileOperation;
import com.owncloud.android.operations.SynchronizeFileOperation;
if(mFile != null){
DataStorageManager storageManager = mContainerActivity.getStorageManager();
- parentDir = storageManager.getFileById(mFile.getParentId());
- mFile = parentDir;
+ if (mFile.getParentId() == 0) {
+ parentDir = storageManager.getFileById(1);
+ }
+ else {
+ parentDir = storageManager.getFileById(mFile.getParentId());
+ }
+
+// // Update folder size on DB
+// storageManager.calculateFolderSize(mFile.getFileId());
+
+ mFile = parentDir;
}
- listDirectory(parentDir);
+
+ if (mFile != null) {
+ listDirectory(mFile);
+
+ mContainerActivity.startSyncFolderOperation(mFile.getRemotePath(), mFile.getFileId());
+ }
+
}
@Override
mList.setSelectionFromTop(0, 0);
}
mFile = directory;
-
}
}
public void startMediaPreview(OCFile file, int i, boolean b);
public void startImagePreview(OCFile file);
+
+ public void startSyncFolderOperation(String remotePath, long parentId);
/**
* Getter for the current DataStorageManager in the container activity
import android.net.Uri;
public class WebdavEntry {
- private String mName, mPath, mUri, mContentType;
+ private String mName, mPath, mUri, mContentType, mEtag;
private long mContentLength, mCreateTimestamp, mModifiedTimestamp;
public WebdavEntry(MultiStatusResponse ms, String splitElement) {
DavPropertySet propSet = ms.getProperties(status);
@SuppressWarnings("rawtypes")
DavProperty prop = propSet.get(DavPropertyName.DISPLAYNAME);
- if (prop != null)
+ if (prop != null) {
mName = (String) prop.getName().toString();
+ mName = mName.substring(1, mName.length()-1);
+ }
else {
String[] tmp = mPath.split("/");
if (tmp.length > 0)
.parseResponseDate((String) prop.getValue());
mCreateTimestamp = (d != null) ? d.getTime() : 0;
}
+
+ prop = propSet.get(DavPropertyName.GETETAG);
+ if (prop != null) {
+ mEtag = (String) prop.getValue();
+ mEtag = mEtag.substring(1, mEtag.length()-1);
+ }
} else {
Log_OC.e("WebdavEntry",
public long modifiedTimestamp() {
return mModifiedTimestamp;
}
+
+ public String etag() {
+ return mEtag;
+ }
private void resetData() {
mName = mUri = mContentType = null;