当前位置: 首页>>代码示例>>Java>>正文


Java DocumentsContract.createDocument方法代码示例

本文整理汇总了Java中android.provider.DocumentsContract.createDocument方法的典型用法代码示例。如果您正苦于以下问题:Java DocumentsContract.createDocument方法的具体用法?Java DocumentsContract.createDocument怎么用?Java DocumentsContract.createDocument使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在android.provider.DocumentsContract的用法示例。


在下文中一共展示了DocumentsContract.createDocument方法的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: doMoveFilesAPI21

import android.provider.DocumentsContract; //导入方法依赖的package包/类
/**
 * Move a file using the new API 21 methods.
 *
 * @param data    File rename data info.
 * @param oldFile Old file reference.
 * @param newFile New file reference.
 * @return True if the file was moved.
 */
@TargetApi(Build.VERSION_CODES.LOLLIPOP)
private boolean doMoveFilesAPI21(Uri oldUri, FileRenameData data, File oldFile, File newFile) throws FileNotFoundException {
    File newParent = newFile.getParentFile();
    Uri newParentUri = mApplication.getDocumentUri(mSelectedFolders, newParent.getAbsolutePath());
    Uri newUri = DocumentsContract.createDocument(mContentResolver, newParentUri,
            data.getMimeType(), newFile.getName());
    boolean result = false;
    long size = 0;
    try {
        if (oldUri != null && newUri != null) {
            size = copyFileWithStreams(oldUri, newUri);
        }
        result = (size > 0);
    } catch (Exception e) {
        mApplication.logE(TAG, "doMoveFilesNewAPI " + oldFile + " to " + newFile, e);
    }
    if (result) {
        result = DocumentsContract.deleteDocument(mContentResolver, oldUri);
        if (result && newFile.exists()) {
            newFile.setLastModified(data.getDateAdded());
        }
    }
    return result;
}
 
开发者ID:ciubex,项目名称:dscautorename,代码行数:33,代码来源:FileRenameThread.java

示例2: createFolder

import android.provider.DocumentsContract; //导入方法依赖的package包/类
@Override
public void createFolder(String new_name)
{
    try
    {
        Uri new_uri = DocumentsContract.createDocument(ctx.getContentResolver(), uri, Document.MIME_TYPE_DIR,
                new_name);
        if (new_uri != null)
        {
            notifyRefr(new_name);
            return;
        }
    }
    catch (Exception e)
    {
        e.printStackTrace();
    }
    notify(ctx.getString(R.string.fman_create_folder_error, new_name), CommanderIf.OPERATION_FAILED);
}
 
开发者ID:mkulesh,项目名称:microMathematics,代码行数:20,代码来源:AdapterDocuments.java

示例3: createFile

import android.provider.DocumentsContract; //导入方法依赖的package包/类
public static Uri createFile(Context context, Uri self, String mimeType,
        String displayName) {
    try {
        return DocumentsContract.createDocument(context.getContentResolver(), self, mimeType,
                displayName);
    } catch (FileNotFoundException e) {
        e.printStackTrace();
        return null;
    }
}
 
开发者ID:gigabytedevelopers,项目名称:FireFiles,代码行数:11,代码来源:DocumentsContractApi21.java

示例4: newFile

import android.provider.DocumentsContract; //导入方法依赖的package包/类
@Override
public Uri newFile(String fileName)
{
    try
    {
        Uri curr = getUri();
        String mime = FileUtils.getMimeByExt(FileUtils.getFileExt(fileName), "*/*");
        return DocumentsContract.createDocument(ctx.getContentResolver(), curr, mime, fileName);
    }
    catch (Exception e)
    {
        e.printStackTrace();
    }
    return null;
}
 
开发者ID:mkulesh,项目名称:microMathematics,代码行数:16,代码来源:AdapterDocuments.java

示例5: createFile

import android.provider.DocumentsContract; //导入方法依赖的package包/类
public static Uri createFile(Context context, Uri self, String mimeType,
        String displayName) {
    try {
        return DocumentsContract.createDocument(context.getContentResolver(), self, mimeType,
                displayName);
    } catch (Exception e) {
        // Maybe user ejects tf card
        Log.e(TAG, "Failed to createFile", e);
        return null;
    }
}
 
开发者ID:seven332,项目名称:UniFile,代码行数:12,代码来源:DocumentsContractApi21.java

示例6: createFile

import android.provider.DocumentsContract; //导入方法依赖的package包/类
public static Uri createFile(Context context, Uri self, String mimeType,
        String displayName) {
    return DocumentsContract.createDocument(context.getContentResolver(), self, mimeType,
            displayName);
}
 
开发者ID:commonsguy,项目名称:cwac-document,代码行数:6,代码来源:DocumentsContractApi21.java

示例7: createFile

import android.provider.DocumentsContract; //导入方法依赖的package包/类
public static Uri createFile(Context context, Uri self, String mimeType, String displayName) {
    return DocumentsContract.createDocument(context.getContentResolver(), self, mimeType, displayName);
}
 
开发者ID:JackChan1999,项目名称:boohee_v5.6,代码行数:4,代码来源:DocumentsContractApi21.java

示例8: createFile

import android.provider.DocumentsContract; //导入方法依赖的package包/类
public static Uri createFile(Context context, Uri self, String mimeType,
        String displayName) throws FileNotFoundException {
    return DocumentsContract.createDocument(context.getContentResolver(), self, mimeType,
            displayName);
}
 
开发者ID:rcketscientist,项目名称:DocumentActivity,代码行数:6,代码来源:DocumentsContractApi21.java

示例9: createFile

import android.provider.DocumentsContract; //导入方法依赖的package包/类
public static Uri createFile(Context context, Uri uri, String s, String s1)
{
    return DocumentsContract.createDocument(context.getContentResolver(), uri, s, s1);
}
 
开发者ID:Hamz-a,项目名称:MyCTFWriteUps,代码行数:5,代码来源:DocumentsContractApi21.java


注:本文中的android.provider.DocumentsContract.createDocument方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。