Android API >= 26,分享收藏数据库崩溃,屏蔽
This commit is contained in:
@@ -12,6 +12,7 @@ import android.database.Cursor;
|
||||
import android.database.sqlite.SQLiteDatabase;
|
||||
import android.graphics.Color;
|
||||
import android.net.Uri;
|
||||
import android.os.Build;
|
||||
import android.os.Bundle;
|
||||
import android.text.Editable;
|
||||
import android.text.TextWatcher;
|
||||
@@ -212,11 +213,17 @@ public class FavoriteActivity extends Activity {
|
||||
case 2:
|
||||
File file = new File(DBHelper.DATABASE_NAME);
|
||||
if (file.exists()) {
|
||||
Intent intent = new Intent();
|
||||
intent.setAction(Intent.ACTION_SEND);
|
||||
intent.putExtra(Intent.EXTRA_STREAM, Uri.fromFile(file));
|
||||
intent.setType("*/*");
|
||||
startActivity(Intent.createChooser(intent, "分享 " + DBHelper.filename));
|
||||
if (Build.VERSION.SDK_INT < Build.VERSION_CODES.O) {
|
||||
Intent intent = new Intent();
|
||||
intent.setAction(Intent.ACTION_SEND);
|
||||
Uri uri = Uri.fromFile(file);
|
||||
//Uri uri = FileProvider.getUriForFile(); //API>=26, FileUriExposedException
|
||||
intent.putExtra(Intent.EXTRA_STREAM, uri);
|
||||
intent.setType("*/*");
|
||||
startActivity(Intent.createChooser(intent, "分享 " + DBHelper.filename));
|
||||
} else {
|
||||
Toast.makeText(getApplicationContext(), "不支持", Toast.LENGTH_SHORT).show();
|
||||
}
|
||||
} else {
|
||||
Toast.makeText(getApplicationContext(), "数据库文件不存在", Toast.LENGTH_SHORT).show();
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user