Follow directory API changes.
Bug: 15429194 Change-Id: Ib30c8c3697dbf883cdbaef5a839ddd9bc0a900d0
This commit is contained in:
@@ -47,7 +47,7 @@ public class DocumentsSample extends Activity {
|
|||||||
|
|
||||||
private static final int CODE_READ = 42;
|
private static final int CODE_READ = 42;
|
||||||
private static final int CODE_WRITE = 43;
|
private static final int CODE_WRITE = 43;
|
||||||
private static final int CODE_PICK = 44;
|
private static final int CODE_TREE = 44;
|
||||||
private static final int CODE_RENAME = 45;
|
private static final int CODE_RENAME = 45;
|
||||||
|
|
||||||
private TextView mResult;
|
private TextView mResult;
|
||||||
@@ -204,15 +204,15 @@ public class DocumentsSample extends Activity {
|
|||||||
view.addView(button);
|
view.addView(button);
|
||||||
|
|
||||||
button = new Button(context);
|
button = new Button(context);
|
||||||
button.setText("PICK_DIRECTORY");
|
button.setText("OPEN_DOC_TREE");
|
||||||
button.setOnClickListener(new OnClickListener() {
|
button.setOnClickListener(new OnClickListener() {
|
||||||
@Override
|
@Override
|
||||||
public void onClick(View v) {
|
public void onClick(View v) {
|
||||||
Intent intent = new Intent(Intent.ACTION_PICK_DIRECTORY);
|
Intent intent = new Intent(Intent.ACTION_OPEN_DOCUMENT_TREE);
|
||||||
if (localOnly.isChecked()) {
|
if (localOnly.isChecked()) {
|
||||||
intent.putExtra(Intent.EXTRA_LOCAL_ONLY, true);
|
intent.putExtra(Intent.EXTRA_LOCAL_ONLY, true);
|
||||||
}
|
}
|
||||||
startActivityForResult(Intent.createChooser(intent, "Kittens!"), CODE_PICK);
|
startActivityForResult(Intent.createChooser(intent, "Kittens!"), CODE_TREE);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
view.addView(button);
|
view.addView(button);
|
||||||
@@ -284,12 +284,12 @@ public class DocumentsSample extends Activity {
|
|||||||
} finally {
|
} finally {
|
||||||
closeQuietly(os);
|
closeQuietly(os);
|
||||||
}
|
}
|
||||||
} else if (requestCode == CODE_PICK) {
|
} else if (requestCode == CODE_TREE) {
|
||||||
// Find existing docs
|
// Find existing docs
|
||||||
Uri doc = DocumentsContract.buildDocumentViaUri(uri,
|
Uri doc = DocumentsContract.buildDocumentUriUsingTree(uri,
|
||||||
DocumentsContract.getViaDocumentId(uri));
|
DocumentsContract.getTreeDocumentId(uri));
|
||||||
Uri child = DocumentsContract.buildChildDocumentsViaUri(uri,
|
Uri child = DocumentsContract.buildChildDocumentsUriUsingTree(uri,
|
||||||
DocumentsContract.getViaDocumentId(uri));
|
DocumentsContract.getTreeDocumentId(uri));
|
||||||
Cursor c = cr.query(child, new String[] {
|
Cursor c = cr.query(child, new String[] {
|
||||||
Document.COLUMN_DISPLAY_NAME, Document.COLUMN_MIME_TYPE }, null, null, null);
|
Document.COLUMN_DISPLAY_NAME, Document.COLUMN_MIME_TYPE }, null, null, null);
|
||||||
try {
|
try {
|
||||||
|
|||||||
Reference in New Issue
Block a user