API Change: MediaScannerConnection.ScanResultListener -> MediaScannerConnection.OnScanCompletedListener.
Change-Id: I1386394dbccda4c01e50d89b8fdeca97ee65a29f
diff --git a/samples/ApiDemos/src/com/example/android/apis/content/ExternalStorage.java b/samples/ApiDemos/src/com/example/android/apis/content/ExternalStorage.java
index d950a2c..534a1c8 100644
--- a/samples/ApiDemos/src/com/example/android/apis/content/ExternalStorage.java
+++ b/samples/ApiDemos/src/com/example/android/apis/content/ExternalStorage.java
@@ -48,17 +48,17 @@
*/
public class ExternalStorage extends Activity {
ViewGroup mLayout;
-
+
static class Item {
View mRoot;
Button mCreate;
Button mDelete;
}
-
+
Item mExternalStoragePublicPicture;
Item mExternalStoragePrivatePicture;
Item mExternalStoragePrivateFile;
-
+
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
@@ -114,10 +114,10 @@
}
});
mLayout.addView(mExternalStoragePrivateFile.mRoot);
-
+
startWatchingExternalStorage();
}
-
+
@Override
protected void onDestroy() {
super.onDestroy();
@@ -135,12 +135,12 @@
mExternalStoragePrivateFile.mCreate.setEnabled(writeable && !has);
mExternalStoragePrivateFile.mDelete.setEnabled(writeable && has);
}
-
+
// BEGIN_INCLUDE(monitor_storage)
BroadcastReceiver mExternalStorageReceiver;
boolean mExternalStorageAvailable = false;
boolean mExternalStorageWriteable = false;
-
+
void updateExternalStorageState() {
String state = Environment.getExternalStorageState();
if (Environment.MEDIA_MOUNTED.equals(state)) {
@@ -154,7 +154,7 @@
handleExternalStorageState(mExternalStorageAvailable,
mExternalStorageWriteable);
}
-
+
void startWatchingExternalStorage() {
mExternalStorageReceiver = new BroadcastReceiver() {
@Override
@@ -169,12 +169,12 @@
registerReceiver(mExternalStorageReceiver, filter);
updateExternalStorageState();
}
-
+
void stopWatchingExternalStorage() {
unregisterReceiver(mExternalStorageReceiver);
}
// END_INCLUDE(monitor_storage)
-
+
// BEGIN_INCLUDE(public_picture)
void createExternalStoragePublicPicture() {
// Create a path where we will place our picture in the user's
@@ -185,11 +185,11 @@
File path = Environment.getExternalStoragePublicDirectory(
Environment.DIRECTORY_PICTURES);
File file = new File(path, "DemoPicture.jpg");
-
+
try {
// Make sure the Pictures directory exists.
path.mkdirs();
-
+
// Very simple code to copy a picture from the application's
// resource into the external file. Note that this code does
// no error checking, and assumes the picture is small (does not
@@ -202,12 +202,12 @@
os.write(data);
is.close();
os.close();
-
+
// Tell the media scanner about the new file so that it is
// immediately available to the user.
MediaScannerConnection.scanFile(this,
new String[] { file.toString() }, null,
- new MediaScannerConnection.ScanResultListener() {
+ new MediaScannerConnection.OnScanCompletedListener() {
public void onScanCompleted(String path, Uri uri) {
Log.i("ExternalStorage", "Scanned " + path + ":");
Log.i("ExternalStorage", "-> uri=" + uri);
@@ -219,7 +219,7 @@
Log.w("ExternalStorage", "Error writing " + file, e);
}
}
-
+
void deleteExternalStoragePublicPicture() {
// Create a path where we will place our picture in the user's
// public pictures directory and delete the file. If external
@@ -229,7 +229,7 @@
File file = new File(path, "DemoPicture.jpg");
file.delete();
}
-
+
boolean hasExternalStoragePublicPicture() {
// Create a path where we will place our picture in the user's
// public pictures directory and check if the file exists. If
@@ -241,7 +241,7 @@
return file.exists();
}
// END_INCLUDE(public_picture)
-
+
// BEGIN_INCLUDE(private_picture)
void createExternalStoragePrivatePicture() {
// Create a path where we will place our picture in our own private
@@ -252,7 +252,7 @@
// your media for display to the user.
File path = getExternalFilesDir(Environment.DIRECTORY_PICTURES);
File file = new File(path, "DemoPicture.jpg");
-
+
try {
// Very simple code to copy a picture from the application's
// resource into the external file. Note that this code does
@@ -266,12 +266,12 @@
os.write(data);
is.close();
os.close();
-
+
// Tell the media scanner about the new file so that it is
// immediately available to the user.
MediaScannerConnection.scanFile(this,
new String[] { file.toString() }, null,
- new MediaScannerConnection.ScanResultListener() {
+ new MediaScannerConnection.OnScanCompletedListener() {
public void onScanCompleted(String path, Uri uri) {
Log.i("ExternalStorage", "Scanned " + path + ":");
Log.i("ExternalStorage", "-> uri=" + uri);
@@ -283,7 +283,7 @@
Log.w("ExternalStorage", "Error writing " + file, e);
}
}
-
+
void deleteExternalStoragePrivatePicture() {
// Create a path where we will place our picture in the user's
// public pictures directory and delete the file. If external
@@ -294,7 +294,7 @@
file.delete();
}
}
-
+
boolean hasExternalStoragePrivatePicture() {
// Create a path where we will place our picture in the user's
// public pictures directory and check if the file exists. If
@@ -308,13 +308,13 @@
return false;
}
// END_INCLUDE(private_picture)
-
+
// BEGIN_INCLUDE(private_file)
void createExternalStoragePrivateFile() {
// Create a path where we will place our private file on external
// storage.
File file = new File(getExternalFilesDir(null), "DemoFile.jpg");
-
+
try {
// Very simple code to copy a picture from the application's
// resource into the external file. Note that this code does
@@ -334,7 +334,7 @@
Log.w("ExternalStorage", "Error writing " + file, e);
}
}
-
+
void deleteExternalStoragePrivateFile() {
// Get path for the file on external storage. If external
// storage is not currently mounted this will fail.
@@ -343,7 +343,7 @@
file.delete();
}
}
-
+
boolean hasExternalStoragePrivateFile() {
// Get path for the file on external storage. If external
// storage is not currently mounted this will fail.
@@ -354,7 +354,7 @@
return false;
}
// END_INCLUDE(private_file)
-
+
Item createStorageControls(CharSequence label, File path,
View.OnClickListener createClick,
View.OnClickListener deleteClick) {