簡體   English   中英

重命名SD卡中的音頻文件

[英]Rename audio file which is in sd card

ListView myList;
List values;
ArrayAdapter adapter;

重命名代碼:

        case CONTEXT_MENU_RENAME:
        AlertDialog.Builder alert = new AlertDialog.Builder(this);
        alert.setTitle("öğeyi yeniden adlandırmak");
        alert.setMessage("Seçili öğe için yeni bir isim girin");
        final EditText input = new EditText(this);
        alert.setView(input);
        alert.setPositiveButton("tamam",
                new DialogInterface.OnClickListener() {
                    public void onClick(DialogInterface dialog,
                            int whichButton) {
                        String value = input.getText().toString();
                        File f = new File(path + filename);
                        if (f != null && f.exists()) {
                            File from = new File(f, f.getName());
                            File to = new File(f, value);
                            from.renameTo(to);
                        }
                        values.set(number_of_item_in_listview, value
                                + ".3gp");
                        adapter.notifyDataSetChanged();
                        /*
                         * File sdcard =
                         * Environment.getExternalStorageDirectory(); File
                         * from = new File(sdcard,"from.txt"); File to = new
                         * File(sdcard,"to.txt"); from.renameTo(to);
                         */

                    }
                });

這是我的代碼來重命名sd卡中的音頻文件,這里我在列表視圖中列出所有音頻文件,然后通過使用contextmenu執行Rename通過使用此代碼),我可以使用新名稱而不是音頻文件來更新我的列表視圖畫廊,怎么做。 幫幫我,謝謝。

使用fullPath到您的文件
像這樣 :

String fromFullPath = /sdcard/example/1.png;
String toFullPath = /sdcard/example/2.png;
File from = new File(fromFullPath);
File to = new File(toFullPath)
from.renameTo(to);

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM