當前位置: 首頁>>代碼示例>>Java>>正文


Java Environment.getDownloadCacheDirectory方法代碼示例

本文整理匯總了Java中android.os.Environment.getDownloadCacheDirectory方法的典型用法代碼示例。如果您正苦於以下問題:Java Environment.getDownloadCacheDirectory方法的具體用法?Java Environment.getDownloadCacheDirectory怎麽用?Java Environment.getDownloadCacheDirectory使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在android.os.Environment的用法示例。


在下文中一共展示了Environment.getDownloadCacheDirectory方法的3個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: uploadFile

import android.os.Environment; //導入方法依賴的package包/類
public static void uploadFile(String address, Callback callback){
        OkHttpClient client = new OkHttpClient();
        File file = new File(Environment.getDownloadCacheDirectory(),"test.jpg");
        Log.d("upload",file.toString());
        RequestBody fileBody = RequestBody.create(MediaType.parse("application/octet-stream"),file);
        Log.d("upload","1");
//        ------WebKitFormBoundaryJ0iuGTPmhsoF94SF
//        Content-Disposition: form-data; name="file"; filename="timg.jpg"
//        Content-Type: image/jpeg
//
//                ------WebKitFormBoundaryJ0iuGTPmhsoF94SF
//        Content-Disposition: form-data; name="submit"

        RequestBody requestBody = new MultipartBody.Builder().setType(MultipartBody.FORM)
//                .addPart(Headers.of("Content-Disposition","form-data; name=\"username\""),RequestBody.create(null,"孫啟鵬"))
                .addPart(Headers.of("Content-Type","image/jpeg"),fileBody)
                .addPart(Headers.of("Content-Disposition","form-data; name=\"submit\""),RequestBody.create(null,"孫啟鵬"))
                .build();
        Log.d("upload","2");
        Request request = new Request.Builder().url(address).post(requestBody).build();
        Log.d("upload","3");
        client.newCall(request).enqueue(callback);
        Log.d("upload","4");
    }
 
開發者ID:newDeepLearing,項目名稱:decoy,代碼行數:25,代碼來源:HttpUtil.java

示例2: getFilesystemRoot

import android.os.Environment; //導入方法依賴的package包/類
/**
 * @return the root of the filesystem containing the given path
 */
public static File getFilesystemRoot(String path) {
    File cache = Environment.getDownloadCacheDirectory();
    if (path.startsWith(cache.getPath())) {
        return cache;
    }
    File external = Environment.getExternalStorageDirectory();
    if (path.startsWith(external.getPath())) {
        return external;
    }
    throw new IllegalArgumentException(
            "Cannot determine filesystem root for " + path);
}
 
開發者ID:snoozinsquatch,項目名稱:unity-obb-downloader,代碼行數:16,代碼來源:Helpers.java

示例3: getFilesystemRoot

import android.os.Environment; //導入方法依賴的package包/類
public static File getFilesystemRoot(String path) {
    File cache = Environment.getDownloadCacheDirectory();
    if (path.startsWith(cache.getPath())) {
        return cache;
    }
    File external = Environment.getExternalStorageDirectory();
    if (path.startsWith(external.getPath())) {
        return external;
    }
    throw new IllegalArgumentException(
            "Cannot determine filesystem root for " + path);
}
 
開發者ID:miLLlulei,項目名稱:Accessibility,代碼行數:13,代碼來源:PathUtils.java


注:本文中的android.os.Environment.getDownloadCacheDirectory方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。