@@ -0,0 +1,2215 @@
+package com.maxiee.heartbeat.database.api;%0A%0Aimport android.content.ContentValues;%0Aimport android.content.Context;%0Aimport android.database.Cursor;%0Aimport android.database.sqlite.SQLiteDatabase;%0Aimport android.net.Uri;%0Aimport android.util.Log;%0A%0Aimport com.maxiee.heartbeat.common.FileUtils;%0Aimport com.maxiee.heartbeat.database.tables.ImageTable;%0A%0A/**%0A * Created by maxiee on 15-9-8.%0A */%0Apublic class ImageUriUpgradeApi %7B%0A    private final static String TAG = ImageUriUpgradeApi.class.getSimpleName();%0A    private final static String URI_CONTENT_PREFIX = %22content://%22;%0A%0A    public static void exec(Context context, SQLiteDatabase db) %7B%0A        Cursor cursor = db.query(%0A                ImageTable.NAME,%0A                new String%5B%5D %7B%0A                        ImageTable.ID,%0A                        ImageTable.URI%0A                %7D,%0A                null,%0A                null, null, null, null%0A        );%0A        if (cursor.getCount() %3C 1) %7B%0A            Log.d(TAG, %22no items in ImageTable%22);%0A            return;%0A        %7D%0A        long%5B%5D ids = new long%5Bcursor.getCount()%5D;%0A        String%5B%5D uris = new String%5Bcursor.getCount()%5D;%0A        int count = 0;%0A        while (cursor.moveToNext()) %7B%0A            ids%5Bcount%5D = cursor.getLong(cursor.getColumnIndex(ImageTable.ID));%0A            uris%5Bcount%5D = cursor.getString(cursor.getColumnIndex(ImageTable.URI));%0A            count++;%0A        %7D%0A        cursor.close();%0A        for (int i=0; i%3Ccount; i++) %7B%0A            updateOrDelete(context, db, ids%5Bi%5D, uris%5Bi%5D);%0A        %7D%0A    %7D%0A%0A    public static void updateOrDelete(Context context, SQLiteDatabase db, long id, String uri) %7B%0A        if (uri.startsWith(URI_CONTENT_PREFIX)) %7B%0A            String ret = FileUtils.uriToPath(context, Uri.parse(uri));%0A            if (ret == null) %7B  // delete%0A                DeleteImageByImageKeyApi.exec(db, id);%0A            %7D else %7B // update%0A                ContentValues values = new ContentValues();%0A                values.put(ImageTable.URI, ret);%0A                db.update(%0A                        ImageTable.NAME,%0A                        values,%0A                        ImageTable.ID + %22=%22 + String.valueOf(id),%0A                        null%0A                );%0A            %7D%0A        %7D%0A    %7D%0A%7D%0A

convert uri to path when upgrade.