Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 3822f73a authored by Marco Nelissen's avatar Marco Nelissen
Browse files

Add a convenience method for getting the media provider version.

b/3350571

Change-Id: I1280a49029aa75643397fab7113b4dd80b639809
parent 04f024d5
Loading
Loading
Loading
Loading
+27 −0
Original line number Original line Diff line number Diff line
@@ -21,6 +21,7 @@ import android.annotation.SdkConstant.SdkConstantType;
import android.content.ContentResolver;
import android.content.ContentResolver;
import android.content.ContentValues;
import android.content.ContentValues;
import android.content.ContentUris;
import android.content.ContentUris;
import android.content.Context;
import android.database.Cursor;
import android.database.Cursor;
import android.database.DatabaseUtils;
import android.database.DatabaseUtils;
import android.database.sqlite.SQLiteException;
import android.database.sqlite.SQLiteException;
@@ -2020,4 +2021,30 @@ public final class MediaStore {
     * the Music app.
     * the Music app.
     */
     */
    public static final String MEDIA_IGNORE_FILENAME = ".nomedia";
    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;
    }

}
}