android 根據Uri獲取檔案目錄
//呼叫錄影
Intent intent = new Intent(MediaStore.ACTION_VIDEO_CAPTURE); startActivityForResult(intent, CASE_VIDEO);
//獲取系統中的視訊
protected void selectFileFromLocal() { Intent intent = new Intent(); intent.setType("video/*"); /* 使用Intent.ACTION_GET_CONTENT這個Action */ intent.setAction(Intent.ACTION_GET_CONTENT); /* 取得相片後返回本畫面 */ startActivityForResult(intent, REQUEST_CODE_SELECT_FILE); }
//獲取視訊庫的目錄
private String getRealPathFromURI(Uri contentURI) { String result; Cursor cursor = getActivity().getContentResolver().query(contentURI, null, null, null, null); if (cursor == null) { // Source is Dropbox or other similar local file pathresult = contentURI.getPath(); } else { cursor.moveToFirst(); int idx = cursor.getColumnIndex(MediaStore.Images.ImageColumns.DATA); result = cursor.getString(idx); cursor.close(); } return result; }
//獲取錄影目錄
@RequiresApi(api = Build.VERSION_CODES.KITKAT) privateString getRealPathFromURIForVideo(Uri selectedVideoUri) { String wholeID = DocumentsContract.getDocumentId(selectedVideoUri); String id = wholeID.split(":")[1]; String[] column = { MediaStore.Video.Media.DATA }; String sel = MediaStore.Video.Media._ID + "=?"; Cursor cursor = getActivity().getContentResolver().query(MediaStore.Video.Media.EXTERNAL_CONTENT_URI, column, sel, new String[]{ id }, null); String filePath = ""; int columnIndex = cursor.getColumnIndex(column[0]); if (cursor.moveToFirst()) { filePath = cursor.getString(columnIndex); } cursor.close(); return filePath; }
相關推薦
android 根據Uri獲取檔案目錄
//呼叫錄影Intent intent = new Intent(MediaStore.ACTION_VIDEO_CAPTURE); startActivityForResult(intent, CASE_VIDEO);//獲取系統中的視訊protected void se
android根據uri或檔案絕對路徑獲取檔案基本資訊
//有需求,於是研究一下 在檔案讀取操作中,很容易能從回撥intent傳遞的資料中獲取檔案uri,從而通過uri獲取檔案絕對路徑, Uri uri = intent.getDataString(); 讀取到uri後,如果檔案為圖片,則可通過 String[] proj =
GetPathFromUri4kitkat【Android 4.4 kitkat以上及以下根據uri獲取路徑的方法】
under als providers textview href 數據權限 res activit nload 版權聲明:本文為博主原創文章,未經博主允許不得轉載。 前言 在Android4.4之前和之後,通過Intent調用文件管理器選擇文件,獲取的文件uri地址形
獲取Android應用程式包檔案目錄---ApplicationInfo
ApplicationInfo是從一個特定的應用得到的資訊。這些資訊是從相對應的Androdimanifest.xml的< application>標籤中收集到的,可獲取應用程式啟動Activity的name。 // 根據查詢條件,查詢特定的ApplicationI
Android獲取檔案目錄
在Android開發過程中,難免會遇到需要檔案操作,這些檔案可以存放在data分割槽下面,也可以存放在外接sd,這些路徑都是什麼呢,今天在這裡做一個簡單的總結。 我一共用了8個系統API,程式碼如下:
android根據Uri得到圖片檔案的真實路徑
/** * Try to return the absolute file path from the given Uri * * @param context * @param uri * @return the file path or null
Android中如何獲取asset目錄下的ini檔案
private void getBootUrl(Context context) throws IOException {Log.d(TAG, "getBootUrl() start");InputStream is = null;BufferedReader in = null;try {is
android 通過uri獲取圖片並根據限制大小讀取圖片的方法
uri = data.getData();BitmapFactory.Options options =newBitmapFactory.Options(); options.inJustDecodeBounds =true;try{Bitm
android中如何獲取指定目錄下的圖片
圖片文件 tor 註意 plain mage 限制 asto tco 語句 需要對指定目錄的圖片文件進行列表,借鑒了網上的方法,發現列表出來是所有的文件,這樣用起來很不方便,在這裏也沒找到解決的辦法,經過自己的進一步研究終於搞定,發上來給有用的同學。用下面這種方式能實現查詢
android根據號碼獲取聯絡人一些總結
1,根據號碼查詢聯絡人: String phoneName = null; Uri uri = Uri.withAppendedPath(PhoneLookup.CONT
android根據URL獲取一級域名
轉載請註明出處:https://blog.csdn.net/u011038298/article/details/84619128 /** * 根據傳入的URL獲取一級域名 * * @param url * @return
Android根據slotid獲取subid
您可以使用類似如下的方法得到subid: private int getSubIdBySlot(int slotId) { Log.d("@M_" + TAG, "SlotId = " + slotId); if (slotId < 0 || slotId >
android okhttp 無法獲取檔案長度問題
使用okhttp 去檔案伺服器下載檔案是,發現無法再response 中獲取到 Content-Type 的值 最後在 StackOverflow 發現有人有類似的問題 給出瞭解決方案,在請求頭中新增 requestBuilder.addHeader("
java根據ContentType獲取檔案字尾名
<dependency> <groupId>org.apache.tika</groupId> <artifactId>tika-core</
Android平臺上獲取檔案的MIME
/** * 使用系統API,根據url獲得對應的MIME型別 */ private String getMimeTypeFromUrl(String url) { String type = null;
自定義android studio的配置檔案目錄後,無法正常安裝和解除安裝外掛的解決辦法。
Android Studio 的快取檔案預設安裝的在C:\Users\YourName\ .xxx 快取一些資料,有限的C盤空間很容易捉禁見肘。所以就需要修改配置檔案了,修改配置檔案的方法百度一下數量數不勝數,我這裡就不寫了。修改路徑後有一個奇葩問題:無法正常安裝和解除安裝外
Android根據時間獲取星期幾
/** * 根據當前日期獲得是星期幾 * time=yyyy-MM-dd * @return */ public static String getWeek(String time) { String Week = ""; SimpleDateFormat fo
Android筆記之獲取檔案MimeType
在Android中獲取檔案TimeType主要通過MimeTypeMap的getFileExtensionFromUrl、getMimeTypeFromExtension方法 privat
Android 根據座標獲取控制元件方法
/** * 根據座標獲取相對應的子控制元件<br> * 在Activity使用 * * @param x座標 * @param y座標 * @return 目標V
關於Mac升級Android Studio無法獲取安裝目錄許可權的解決辦法
Android Studio3.0 Canary1升級版本2時,報錯Studio does not have write access to /private/var/folders/解決辦法: Terminal中輸入 sudo /Applications/Android\