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


Java DocumentsContract.renameDocument方法代码示例

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


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

示例1: renameItem

import android.provider.DocumentsContract; //导入方法依赖的package包/类
@Override
public boolean renameItem(int position, String newName)
{
    ContentResolver cr = ctx.getContentResolver();
    Item item = items[position - 1];
    Uri new_uri = null;
    try
    {
        new_uri = DocumentsContract.renameDocument(cr, (Uri) item.origin, newName);
    }
    catch (FileNotFoundException e)
    {
        e.printStackTrace();
        return false;
    }
    if (new_uri == null)
    {
        return false;
    }
    item.origin = new_uri;
    notifyRefr(newName);
    return true;
}
 
开发者ID:mkulesh,项目名称:microMathematics,代码行数:24,代码来源:AdapterDocuments.java

示例2: renameBook

import android.provider.DocumentsContract; //导入方法依赖的package包/类
@Override
public VersionedRook renameBook(Uri from, String name) throws IOException {
    DocumentFile fromDocFile = DocumentFile.fromSingleUri(context, from);
    BookName bookName = BookName.fromFileName(fromDocFile.getName());
    String newFileName = BookName.fileName(name, bookName.getFormat());

    /* Check if document already exists. */
    DocumentFile existingFile = repoDocumentFile.findFile(newFileName);
    if (existingFile != null) {
        throw new IOException("File at " + existingFile.getUri() + " already exists");
    }

    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
        Uri newUri = DocumentsContract.renameDocument(context.getContentResolver(), from, newFileName);

        long mtime = fromDocFile.lastModified();
        String rev = String.valueOf(mtime);

        return new VersionedRook(getUri(), newUri, rev, mtime);

    } else {
        /*
         * This should never happen, unless the user downgraded
         * and uses the same repo uri.
         */
        throw new IOException("Renaming notebooks is not supported on your device " +
                              "(requires at least Lollipop)");
    }
}
 
开发者ID:orgzly,项目名称:orgzly-android,代码行数:30,代码来源:ContentRepo.java

示例3: renameTo

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

示例4: renameTo

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

示例5: doRenameFilesNewAPI

import android.provider.DocumentsContract; //导入方法依赖的package包/类
/**
 * Move a file using the new API methods.
 *
 * @param data    File rename data info.
 * @param oldFile Old file reference.
 * @param newFile New file reference.
 * @return New file URI.
 */
@TargetApi(Build.VERSION_CODES.LOLLIPOP)
private Uri doRenameFilesNewAPI(FileRenameData data, File oldFile, File newFile) throws FileNotFoundException {
    Uri oldUri = mApplication.getDocumentUri(mSelectedFolders, oldFile.getAbsolutePath());
    Uri newUri = null;
    if (oldUri != null) {
        newUri = DocumentsContract.renameDocument(mContentResolver, oldUri, newFile.getName());
    }
    return newUri;
}
 
开发者ID:ciubex,项目名称:dscautorename,代码行数:18,代码来源:FileRenameThread.java

示例6: renameTo

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

示例7: renameTo

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

示例8: renameTo

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


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