0

所以我在我的应用程序中有 Preference EditText 并且我想从 EditText 获取该文本并将其用作此代码中的文件名String path = getFullFilePath(getApplicationContext(), filename);我已经尝试过:

   SharedPreferences getPrefs = PreferenceManager
        .getDefaultSharedPreferences(getBaseContext());
SharedPreferences settings = getSharedPreferences("EditText",0);
String zipStr = settings.getString("ime", "");  
sp = new SoundPool(5, AudioManager.STREAM_MUSIC, 0);
String path = getFullFilePath(getApplicationContext(), zipStr);
mSoundId = sp.load(path, 1);

LogCat 说:示例 1 尚未准备好

使用String path = getFullFilePath(getApplicationContext(), "SONG NAME"); 在外部存储上查找歌曲,soundpool 使用它。我想要的只是使用 EditText Text,除了“SONG NAME”

4

1 回答 1

0

您是否确认您有一个名称存储在您的首选项中的文件?Log.d("TAG", "Path: " + path)在您的行之后添加String path = getFullFilePath(getApplicationContext(), zipStr);并查看您的路径字符串实际包含的内容以及您实际上在该位置有一个具有该名称的文件。

于 2012-11-05T21:54:23.617 回答