重命名sd卡中的音频文件

时间:2013-12-30 07:57:50

标签: android audio

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卡中的音频文件,这里我列出了列表视图中的所有音频文件,然后使用上下文菜单执行Rename使用此代码,我可以更新我的列表视图新名称,但不是画廊中的音频文件,如何做到这一点。帮帮我谢谢。

1 个答案:

答案 0 :(得分:0)

使用文件的完整路径 像这样:

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);