本文整理汇总了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;
}
示例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);
}
示例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;
}
}
示例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;
}
示例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;
}
}
示例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);
}
示例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);
}
示例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);
}
示例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);
}