mirror of
https://github.com/RfidResearchGroup/RFIDtools.git
synced 2026-05-12 11:19:59 -07:00
add some string
This commit is contained in:
@@ -354,43 +354,52 @@ public class FileUtils {
|
||||
|
||||
private static String getFilePathByUri_BELOWAPI11(Uri uri) {
|
||||
// 以 content:// 开头的,比如 content://media/extenral/images/media/17766
|
||||
if (ContentResolver.SCHEME_CONTENT.equals(uri.getScheme())) {
|
||||
String path = null;
|
||||
String[] projection = new String[]{MediaStore.Images.Media.DATA};
|
||||
Cursor cursor = context.getContentResolver().query(uri, projection, null, null, null);
|
||||
try {
|
||||
if (ContentResolver.SCHEME_CONTENT.equals(uri.getScheme())) {
|
||||
String path = null;
|
||||
String[] projection = new String[]{MediaStore.Images.Media.DATA};
|
||||
Cursor cursor = context.getContentResolver().query(uri, projection, null, null, null);
|
||||
if (cursor != null) {
|
||||
if (cursor.moveToFirst()) {
|
||||
try {
|
||||
int columnIndex = cursor.getColumnIndexOrThrow(MediaStore.Images.Media.DATA);
|
||||
if (columnIndex > -1) {
|
||||
path = cursor.getString(columnIndex);
|
||||
}
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
cursor.close();
|
||||
}
|
||||
return path;
|
||||
}
|
||||
} catch (Exception e) {
|
||||
return null;
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
private static String getFilePathByUri_API11to18(Uri contentUri) {
|
||||
String result = null;
|
||||
try {
|
||||
String[] projection = {MediaStore.Images.Media.DATA};
|
||||
|
||||
CursorLoader cursorLoader = new CursorLoader(context, contentUri, projection, null, null, null);
|
||||
Cursor cursor = cursorLoader.loadInBackground();
|
||||
if (cursor != null) {
|
||||
if (cursor.moveToFirst()) {
|
||||
try {
|
||||
int columnIndex = cursor.getColumnIndexOrThrow(MediaStore.Images.Media.DATA);
|
||||
if (columnIndex > -1) {
|
||||
path = cursor.getString(columnIndex);
|
||||
}
|
||||
int column_index = cursor.getColumnIndexOrThrow(MediaStore.Images.Media.DATA);
|
||||
result = cursor.getString(column_index);
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
cursor.close();
|
||||
}
|
||||
return path;
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
private static String getFilePathByUri_API11to18(Uri contentUri) {
|
||||
String[] projection = {MediaStore.Images.Media.DATA};
|
||||
String result = null;
|
||||
CursorLoader cursorLoader = new CursorLoader(context, contentUri, projection, null, null, null);
|
||||
Cursor cursor = cursorLoader.loadInBackground();
|
||||
if (cursor != null) {
|
||||
if (cursor.moveToFirst()) {
|
||||
try {
|
||||
int column_index = cursor.getColumnIndexOrThrow(MediaStore.Images.Media.DATA);
|
||||
result = cursor.getString(column_index);
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
cursor.close();
|
||||
} catch (Exception e) {
|
||||
return null;
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user