当前位置: 首页>>代码示例>>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;未经允许,请勿转载。