[英]Rename file and overwrite it again
我正在嘗試使用以下步驟重命名畫廊中的文件
從設備獲取文件路徑,然后重命名路徑,但是它不會在本地路徑上重命名
我想用新名稱覆蓋它
picturePath = cursor.getString(columnIndex);// real pic path on my device after getting it from gallery
File photo = new File(picturePath);
File newFile= new File(picturePath,"hhhhhhh");
photo.renameTo(newFile);
如果picturePath是完整路徑(path + filename),則在第二次調用時,您嘗試將newFile對象定義為(path + filename + newname)。 例如,您擁有/some/where/photo.jpg並將其重命名為/some/where/photo.jpg/hhhhhhh。 我猜你在那里需要一個getPath()。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.