summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
author Marco Nelissen <marcone@google.com> 2011-02-03 11:06:07 -0800
committer Android (Google) Code Review <android-gerrit@google.com> 2011-02-03 11:06:07 -0800
commitd2f5d166c5678803dc2b13f3f1b91be0446d8b72 (patch)
tree8ddd2c4b1d8c90e010df067a40394e051c7fe1f1
parent9ebd580231961b3fa97558e5e6cbc8a0f0cbfd43 (diff)
parent3822f73a58af67ea7955f926c7d10335d86572c0 (diff)
Merge "Add a convenience method for getting the media provider version."
-rw-r--r--core/java/android/provider/MediaStore.java27
1 files changed, 27 insertions, 0 deletions
diff --git a/core/java/android/provider/MediaStore.java b/core/java/android/provider/MediaStore.java
index 4c1fb5b7cb2d..b3746da91c73 100644
--- a/core/java/android/provider/MediaStore.java
+++ b/core/java/android/provider/MediaStore.java
@@ -21,6 +21,7 @@ import android.annotation.SdkConstant.SdkConstantType;
import android.content.ContentResolver;
import android.content.ContentValues;
import android.content.ContentUris;
+import android.content.Context;
import android.database.Cursor;
import android.database.DatabaseUtils;
import android.database.sqlite.SQLiteException;
@@ -2020,4 +2021,30 @@ public final class MediaStore {
* the Music app.
*/
public static final String MEDIA_IGNORE_FILENAME = ".nomedia";
+
+ /**
+ * Get the media provider's version.
+ * Applications that import data from the media provider into their own caches
+ * can use this to detect that the media provider changed, and reimport data
+ * as needed. No other assumptions should be made about the meaning of the version.
+ * @param context Context to use for performing the query.
+ * @return A version string, or null if the version could not be determined.
+ * @hide
+ */
+ public static String getVersion(Context context) {
+ Cursor c = context.getContentResolver().query(
+ Uri.parse(CONTENT_AUTHORITY_SLASH + "none/version"),
+ null, null, null, null);
+ if (c != null) {
+ try {
+ if (c.moveToFirst()) {
+ return c.getString(0);
+ }
+ } finally {
+ c.close();
+ }
+ }
+ return null;
+ }
+
}