【发布时间】:2013-10-28 17:58:12
【问题描述】:
我试图将一个 mp3 文件保存到我的应用程序 res/raw/ 文件夹中,但我实际上不知道如何执行此操作..
当按钮为clicked时
OnClickListener button2 = new OnClickListener(){
@Override
public void onClick(View v) {
Intent intent = new Intent(Intent.ACTION_GET_CONTENT);
intent.setType("file/*");
int YOUR_RESULT_CODE = 0;
intent.getData();
startActivityForResult(intent, YOUR_RESULT_CODE);
}
};
那是因为我想使用文件资源管理器来选择我的 .mp3 文件类型
现在如何将所选文件保存到特定文件夹 (res/raw) into my application
public File getTempFile(Context context, String url) {
//should i add something here?
File file1 = null;
try {
String FileName = Uri.parse(url).getLastPathSegment();
file1 = File.createTempFile(FileName, null, context.getCacheDir());
}
catch (IOException e) {
}
return file1;
}
如果您的示例包含code,我将不胜感激
在此先感谢:)
【问题讨论】:
-
你的意思是你只想将你应用程序中的 mp3 文件从一个文件夹复制到另一个文件夹?
-
从 sd 卡(或手机内存)到我的应用程序文件夹
-
好吧,你的意思是断言文件夹?
标签: android file android-intent save