我正在制作一个聊天应用程序,其中用户也可以选择发送图片。我想将图像保存到应用程序文件夹中,以便我可以访问这些图像,以便使用图片和文本填充聊天窗口。所以我的问题是如何将图像添加到应用程序文件夹? 感谢将图像保存在应用程序文件夹中?
-1
A
回答
1
首先你要创建的应用程序名称的文件夹到SD卡,那么你有你的文件/图片写进去
String SDCardRoot = Environment.getExternalStorageDirectory().toString();
String filename = "fileName" + ".jpg";
File myDir = new File(SDCardRoot + "/AppName");
myDir.mkdirs();
File file = new File(myDir, filename);
FileOutputStream fileOutput = new FileOutputStream(file);
//write the file into the sdcard folder specify your buffer , bufferLength
fileOutput.write(buffer, 0, bufferLength);
fileOutput.close();
那么只有你可以从应用程序文件夹中访问这些文件
File imgFile;
String path = Environment.getExternalStorageDirectory() + "/AppName/" + ".jpg";
imgFile = new File(path);
if (imgFile.exists()) {
Bitmap bitmap = BitmapFactory.decodeFile(imgFile.getAbsolutePath());
imageView.setImageBitmap(bitmap);
}
+0
非常感谢您的帮助! – revipod
+0
欢迎,如果它对你有帮助,然后接受我的答案 –
相关问题
- 1. 将图像保存到应用程序文件夹中
- 2. iPhone - UIImagePickerController - >将图像保存到应用程序文件夹
- 3. 将png文件保存在应用程序图像文件夹中而不使用保存对话框文件
- 4. 将文件保存在应用程序文件夹中
- 5. UWP应用程序试图将文件保存到文件夹
- 6. 在Silverlight的应用程序图像文件夹中保存PNG文件
- 7. 将图像保存到照片文件夹在hololens应用程序
- 8. 如何将图像文件保存到应用程序中?
- 9. PhoneGap - 如何复制图像并保存在应用程序文件夹中?
- 10. 将图像保存在应用程序文档中
- 11. 将文件保存到MyDocuments +应用程序文件夹
- 12. Android:将图像保存到文件夹
- 13. C#:将图像保存到文件夹
- 14. 将图像文件保存到IBM Bluemix Node.js应用程序
- 15. 将图像/视频文件保存到子文件夹中的应用程序内部存储器
- 16. ios:缓存应用程序文件夹中的图像
- 17. 使用for循环将图像保存在文件夹中
- 18. 将文件保存在Windows 8应用程序的本地文件夹中
- 19. 错误:试图将文件保存到UWP应用程序文件夹
- 20. 将我的图片文件夹中的图像保存到Windows 8中的本地应用程序文件夹Metro应用程序
- 21. 从iOS上的UIView保存图像到应用程序文档文件夹
- 22. ios应用程序中保存图像
- 23. 将图像存储在iOS应用程序的xml文件中
- 24. 在应用程序的保存箱中创建文件夹
- 25. 将BitMapImage保存到应用程序文件夹
- 26. 如何将JDeveloper 11g应用程序保存到新文件夹?
- 27. 如何从iPhone的应用程序文档文件夹中将图像保存在我的设备图像库文件夹中?
- 28. 无法将图像保存在Android应用程序中
- 29. 使用matlab保存文件夹中的图像序列
- 30. 将VB.net aspx web应用程序中的XML文件保存到文件夹
我假设你是指包应用程序可绘制文件夹。不知道你能做到这一点。您必须使用应用程序缓存存储或内部/外部存储文件夹,您可以在其中创建和存储图像 – Tasos