廢話不多說,直切主題
如圖:
修改文件夾在PC上的文件夾名:
在frameworks/base/media/java/android/mtp 下找到MtpProertyGroup.java源文件
在MtpPropertyList getPropertyList(int handle, int format, int depth)函數中的case MtpConstants.PROPERTY_OBJECT_FILE_NAME:添加如下代碼
注意我這裏是只修改根目錄下的文件,Pictures、Movies、Music分別改成 我的圖片、我的視頻、我的音樂,parent == 0表示是在根目錄
還有一點要注意
int parent = queryInt(handle, Files.FileColumns.PARENT);
中的查詢是
private Integer queryInt(int id, String column) {
Cursor c = null;
try {
// for now we are only reading properties from the "objects" table
c = mProvider.query(mPackageName, mUri,
new String [] { Files.FileColumns._ID, column },
ID_WHERE, new String[] { Integer.toString(id) }, null, null);
if (c != null && c.moveToNext()) {
return new Integer(c.getInt(1));
}
} catch (Exception e) {
} finally {
if (c != null) {
c.close();
}
}
return null;
}
就這麼多了,下一篇關於MTP模式下如何禁止PC端在根目錄創建文件夾、修改文件名、刪除文件夾等