- return null;
- }
-
- public String getMimetype() {
- return mimetype_;
- }
-
- public void save() {
- ContentValues cv = new ContentValues();
- cv.put(ProviderTableMeta.FILE_MODIFIED, modified_timestamp_);
- cv.put(ProviderTableMeta.FILE_CREATION, creation_timestamp_);
- cv.put(ProviderTableMeta.FILE_CONTENT_LENGTH, length_);
- cv.put(ProviderTableMeta.FILE_CONTENT_TYPE, mimetype_);
- cv.put(ProviderTableMeta.FILE_NAME, getFileName());
- if (parent_id_ != 0)
- cv.put(ProviderTableMeta.FILE_PARENT, parent_id_);
- cv.put(ProviderTableMeta.FILE_PATH, path_);
- cv.put(ProviderTableMeta.FILE_STORAGE_PATH, storage_path_);
- cv.put(ProviderTableMeta.FILE_ACCOUNT_OWNER, account_.name);
-
- if (fileExtist()) {
- if (cp_ != null) {
- try {
- cp_.update(ProviderTableMeta.CONTENT_URI, cv, ProviderTableMeta._ID
- + "=?", new String[]{String.valueOf(id_)});
- } catch (RemoteException e) {
- Log.e(TAG, e.getMessage());
- return;
- }
- } else {
- cr_.update(ProviderTableMeta.CONTENT_URI, cv, ProviderTableMeta._ID
- + "=?", new String[]{String.valueOf(id_)});
- }
- } else {
- Uri new_entry = null;
- if (cp_ != null) {
- try {
- new_entry = cp_.insert(ProviderTableMeta.CONTENT_URI_FILE, cv);
- } catch (RemoteException e) {
- Log.e(TAG, e.getMessage());
- id_ = -1;
- return;
+
+ /**
+ * Can be used to check, whether or not this file exists in the database
+ * already
+ *
+ * @return true, if the file exists in the database
+ */
+ public boolean fileExists() {
+ return mId != -1;
+ }
+
+ /**
+ * Use this to find out if this file is a Directory
+ *
+ * @return true if it is a directory
+ */
+ public boolean isDirectory() {
+ return mMimeType != null && mMimeType.equals("DIR");
+ }
+
+ /**
+ * Use this to check if this file is available locally
+ *
+ * @return true if it is
+ */
+ public boolean isDownloaded() {
+ return mLocalPath != null || mLocalPath.equals("");
+ }
+
+ /**
+ * The path, where the file is stored locally
+ *
+ * @return The local path to the file
+ */
+ public String getStoragePath() {
+ return mLocalPath;
+ }
+
+ /**
+ * Can be used to set the path where the file is stored
+ *
+ * @param storage_path to set
+ */
+ public void setStoragePath(String storage_path) {
+ mLocalPath = storage_path;
+ }
+
+ /**
+ * Get a UNIX timestamp of the file creation time
+ *
+ * @return A UNIX timestamp of the time that file was created
+ */
+ public long getCreationTimestamp() {
+ return mCreationTimestamp;
+ }
+
+ /**
+ * Set a UNIX timestamp of the time the file was created
+ *
+ * @param creation_timestamp to set
+ */
+ public void setCreationTimestamp(long creation_timestamp) {
+ mCreationTimestamp = creation_timestamp;
+ }
+
+ /**
+ * Get a UNIX timestamp of the file modification time
+ *
+ * @return A UNIX timestamp of the modification time
+ */
+ public long getModificationTimestamp() {
+ return mModifiedTimestamp;
+ }
+
+ /**
+ * Set a UNIX timestamp of the time the time the file was modified.
+ *
+ * @param modification_timestamp to set
+ */
+ public void setModificationTimestamp(long modification_timestamp) {
+ mModifiedTimestamp = modification_timestamp;
+ }
+
+ /**
+ * Returns the filename and "/" for the root directory
+ *
+ * @return The name of the file
+ */
+ public String getFileName() {
+ if (mRemotePath != null) {
+ File f = new File(mRemotePath);
+ return f.getName().equals("") ? "/" : f.getName();