java如何以编程方式在Android中的google drive中创建应用程序文件夹中的文件夹
我使用Android中的GoogleDrive API以编程方式将数据存储在GoogleDrive中。我提到这一点。但它用于在根文件夹中创建文件夹,而不是在应用程序文件夹中创建文件夹。是否可以在AppFolder
中创建文件夹?
我尝试了一些,但没有结果我尝试的代码
public class CreateFolderInAppFolder extends BaseDemoActivity {
@Override
public void onConnected(Bundle connectionHint) {
super.onConnected(connectionHint);
MetadataChangeSet changeSet = new MetadataChangeSet.Builder()
.setTitle("New folder").build();
DriveApi.getAppFolder(getGoogleApiClient()).createFolder(
getGoogleApiClient(), changeSet).setResultCallback(callback);
}
final ResultCallback<DriveFolderResult> callback = new ResultCallback<DriveFolderResult>() {
@Override
public void onResult(DriveFolderResult result) {
if (!result.getStatus().isSuccess()) {
showMessage("Error while trying to create the folder");
return;
}
showMessage("Created a folder: " + result.getDriveFolder().getDriveId());
}
};
}
# 1 楼答案
是的,这是可能的,试着阅读Storing Application Data:
在App文件夹中创建一个文件
下面是一个示例代码:
您可以通过检索其metadata来检查文件/文件夹是否在AppFolder中。如果文件或文件夹在App文件夹中,^{} 方法返回
true
希望这有帮助