@@ -0,0 +1,2033 @@
+/**%0A * Copyright 2014 Zhenguo Jin (jingle1267@163.com)%0A *%0A * Licensed under the Apache License, Version 2.0 (the %22License%22);%0A * you may not use this file except in compliance with the License.%0A * You may obtain a copy of the License at%0A *%0A *   http://www.apache.org/licenses/LICENSE-2.0%0A *%0A * Unless required by applicable law or agreed to in writing, software%0A * distributed under the License is distributed on an %22AS IS%22 BASIS,%0A * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.%0A * See the License for the specific language governing permissions and%0A * limitations under the License.%0A */%0Apackage com.worthed.utils;%0A%0Aimport android.content.Context;%0Aimport android.os.Environment;%0Aimport android.text.TextUtils;%0A%0A/**%0A * %E5%BA%94%E7%94%A8%E6%95%B0%E6%8D%AE%E5%BA%93%E5%AF%BC%E5%87%BA%E5%B7%A5%E5%85%B7%E7%B1%BB%0A * %0A * @author jingle1267@163.com%0A * %0A */%0Apublic class DatabaseExportUtils %7B%0A%0A%09private static final boolean DEBUG = true;%0A%09private static final String TAG = %22DatabaseExportUtils%22;%0A%0A%09/**%0A%09 * %E5%BC%80%E5%A7%8B%E5%AF%BC%E5%87%BA%E6%95%B0%E6%8D%AE %E6%AD%A4%E6%93%8D%E4%BD%9C%E6%AF%94%E8%BE%83%E8%80%97%E6%97%B6,%E5%BB%BA%E8%AE%AE%E5%9C%A8%E7%BA%BF%E7%A8%8B%E4%B8%AD%E8%BF%9B%E8%A1%8C%0A%09 * %0A%09 * @param context%0A%09 * @param targetFile%0A%09 *            %E7%9B%AE%E6%A0%87%E6%96%87%E4%BB%B6%0A%09 * @param databaseName%0A%09 *            %E8%A6%81%E6%8B%B7%E8%B4%9D%E7%9A%84%E6%95%B0%E6%8D%AE%E5%BA%93%E6%96%87%E4%BB%B6%E5%90%8D%0A%09 * @return%0A%09 */%0A%09public boolean startExportDatabase(Context context, String targetFile,%0A%09%09%09String databaseName) %7B%0A%09%09if (DEBUG) %7B%0A%09%09%09LogUtils.d(TAG, %22start export ...%22);%0A%09%09%7D%0A%09%09if (!Environment.MEDIA_MOUNTED.equals(Environment%0A%09%09%09%09.getExternalStorageState())) %7B%0A%09%09%09if (DEBUG) %7B%0A%09%09%09%09LogUtils.w(TAG, %22cannot find SDCard%22);%0A%09%09%09%7D%0A%09%09%09return false;%0A%09%09%7D%0A%09%09String sourceFilePath = Environment.getDataDirectory() + %22/data/%22%0A%09%09%09%09+ context.getPackageName() + %22/databases/%22 + databaseName;%0A%09%09String destFilePath = Environment.getExternalStorageDirectory()%0A%09%09%09%09+ (TextUtils.isEmpty(targetFile) ? (context.getPackageName() + %22.db%22)%0A%09%09%09%09%09%09: targetFile);%0A%09%09boolean isCopySuccess = FileUtils%0A%09%09%09%09.copyFile(sourceFilePath, destFilePath);%0A%09%09if (DEBUG) %7B%0A%09%09%09if (isCopySuccess) %7B%0A%09%09%09%09LogUtils.d(TAG, %22copy database file success. target file : %22%0A%09%09%09%09%09%09+ destFilePath);%0A%09%09%09%7D else %7B%0A%09%09%09%09LogUtils.w(TAG, %22copy database file failure%22);%0A%09%09%09%7D%0A%09%09%7D%0A%09%09return isCopySuccess;%0A%09%7D%0A%7D%0A

Add database export util.