本文整理汇总了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;
}
示例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)");
}
}
示例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;
}
}
示例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;
}
}
示例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;
}
示例6: renameTo
import android.provider.DocumentsContract; //导入方法依赖的package包/类
public static Uri renameTo(Context context, Uri self, String displayName) {
return DocumentsContract.renameDocument(context.getContentResolver(), self, displayName);
}
示例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);
}
示例8: renameTo
import android.provider.DocumentsContract; //导入方法依赖的package包/类
public static Uri renameTo(Context context, Uri uri, String s)
{
return DocumentsContract.renameDocument(context.getContentResolver(), uri, s);
}