我正在编写一个应用程序,用于存储用户的个人资料信息和联系方式。用户资料和联系信息还包括图像/位图。我想将图像存储在内部存储中,并使用
Picasso
库显示图像。我希望应用程序创建一个个人资料目录来存储个人资料图像,同样地,也要为联系人创建一个目录。我想使用Picasso
从文件中检索图像,并在ImvageView上显示它,如下所示。Picasso.with(context)
.placeholder(R.drawable.user_placeholder)
.error(R.drawable.user_placeholder_error)
.load("file:///somepath/profile.png")
.into(imageView);
我不确定应用程序如何创建子目录并存储图片。提供给Picasso
加载图像到ImageView
的路径是什么?
编辑1
我认为可以使用getApplicationContext().getFilesDir().getAbsolutePath()
来获取路径,但我还不确定如何为个人资料和联系人创建子目录?
try { FileOutputStream out = new FileOutputStream(myImage); outputImage.compress(Bitmap.CompressFormat.JPEG, 80, out); out.flush(); out.close(); } catch (Exception e) { e.printStackTrace(); }`
- Kumari SwetaFileOutputStream
写入文件,但是您需要从某个地方获取图像数据... - ris8_allo_zen0