1616
1717package android .os .storage ;
1818
19+ import android .content .Context ;
1920import android .os .Parcel ;
2021import android .os .Parcelable ;
2122
@@ -28,7 +29,7 @@ public class StorageVolume implements Parcelable {
2829 //private static final String TAG = "StorageVolume";
2930
3031 private final String mPath ;
31- private final String mDescription ;
32+ private final int mDescriptionId ;
3233 private final boolean mRemovable ;
3334 private final boolean mEmulated ;
3435 private final int mMtpReserveSpace ;
@@ -42,10 +43,10 @@ public class StorageVolume implements Parcelable {
4243 // ACTION_MEDIA_BAD_REMOVAL, ACTION_MEDIA_UNMOUNTABLE and ACTION_MEDIA_EJECT broadcasts.
4344 public static final String EXTRA_STORAGE_VOLUME = "storage_volume" ;
4445
45- public StorageVolume (String path , String description , boolean removable ,
46+ public StorageVolume (String path , int descriptionId , boolean removable ,
4647 boolean emulated , int mtpReserveSpace , boolean allowMassStorage , long maxFileSize ) {
4748 mPath = path ;
48- mDescription = description ;
49+ mDescriptionId = descriptionId ;
4950 mRemovable = removable ;
5051 mEmulated = emulated ;
5152 mMtpReserveSpace = mtpReserveSpace ;
@@ -54,11 +55,11 @@ public StorageVolume(String path, String description, boolean removable,
5455 }
5556
5657 // for parcelling only
57- private StorageVolume (String path , String description , boolean removable ,
58+ private StorageVolume (String path , int descriptionId , boolean removable ,
5859 boolean emulated , int mtpReserveSpace , int storageId ,
5960 boolean allowMassStorage , long maxFileSize ) {
6061 mPath = path ;
61- mDescription = description ;
62+ mDescriptionId = descriptionId ;
6263 mRemovable = removable ;
6364 mEmulated = emulated ;
6465 mMtpReserveSpace = mtpReserveSpace ;
@@ -81,8 +82,12 @@ public String getPath() {
8182 *
8283 * @return the volume description
8384 */
84- public String getDescription () {
85- return mDescription ;
85+ public String getDescription (Context context ) {
86+ return context .getResources ().getString (mDescriptionId );
87+ }
88+
89+ public int getDescriptionId () {
90+ return mDescriptionId ;
8691 }
8792
8893 /**
@@ -172,8 +177,8 @@ public int hashCode() {
172177
173178 @ Override
174179 public String toString () {
175- return "StorageVolume [mAllowMassStorage=" + mAllowMassStorage + ", mDescription ="
176- + mDescription + ", mEmulated=" + mEmulated + ", mMaxFileSize=" + mMaxFileSize
180+ return "StorageVolume [mAllowMassStorage=" + mAllowMassStorage + ", mDescriptionId ="
181+ + mDescriptionId + ", mEmulated=" + mEmulated + ", mMaxFileSize=" + mMaxFileSize
177182 + ", mMtpReserveSpace=" + mMtpReserveSpace + ", mPath=" + mPath + ", mRemovable="
178183 + mRemovable + ", mStorageId=" + mStorageId + "]" ;
179184 }
@@ -182,14 +187,14 @@ public String toString() {
182187 new Parcelable .Creator <StorageVolume >() {
183188 public StorageVolume createFromParcel (Parcel in ) {
184189 String path = in .readString ();
185- String description = in .readString ();
190+ int descriptionId = in .readInt ();
186191 int removable = in .readInt ();
187192 int emulated = in .readInt ();
188193 int storageId = in .readInt ();
189194 int mtpReserveSpace = in .readInt ();
190195 int allowMassStorage = in .readInt ();
191196 long maxFileSize = in .readLong ();
192- return new StorageVolume (path , description ,
197+ return new StorageVolume (path , descriptionId ,
193198 removable == 1 , emulated == 1 , mtpReserveSpace ,
194199 storageId , allowMassStorage == 1 , maxFileSize );
195200 }
@@ -205,7 +210,7 @@ public int describeContents() {
205210
206211 public void writeToParcel (Parcel parcel , int flags ) {
207212 parcel .writeString (mPath );
208- parcel .writeString ( mDescription );
213+ parcel .writeInt ( mDescriptionId );
209214 parcel .writeInt (mRemovable ? 1 : 0 );
210215 parcel .writeInt (mEmulated ? 1 : 0 );
211216 parcel .writeInt (mStorageId );
0 commit comments