[英]How to access this internal storage directory?
I need to access this internal storage folder: /data/data/com.ceriosrey.chattrbox/app_imageDir
我需要访问此内部存储文件夹:
/data/data/com.ceriosrey.chattrbox/app_imageDir
This is how i saved into it: 这是我保存到其中的方式:
val cw = ContextWrapper(context)
val directory = cw.getDir("imageDir", Context.MODE_PRIVATE)
val mypath = File(directory, imageName + ".jpg")
This is my attempt at trying to get to it to fetch the images: 这是我尝试获取图像的尝试:
//loading image here
val essentialsActivity = EssentialsActivity()
val context = essentialsActivity.baseContext
val directory = context.getDir("imageDir", Context.MODE_PRIVATE)
val mypath = File(directory.absolutePath, chattRitem.itemImageFileName )
Picasso.get().load(mypath).into(itemView.imageView_essentials_image) }
So basically, I need to get the path so i can use it in the load parameter for load() in picasso. 所以基本上,我需要获取路径,以便可以在毕加索的load()的load参数中使用它。 Please help.
请帮忙。
this is an actual file inside that folder: 这是该文件夹中的实际文件:
/Users/myname/Documents/AndroidStudio/DeviceExplorer/Nexus_6P_API_P [emulator-5554]/data/data/com.ceriosrey.chattrbox/app_imageDir/0f0e9b44-9833-4224-8343-8da203d782cf_bigstep.jpg.jpg
/ Users / myname / Documents / AndroidStudio / DeviceExplorer / Nexus_6P_API_P [emulator-5554] /data/data/com.ceriosrey.chattrbox/app_imageDir/0f0e9b44-9833-4224-8343-8da203d782cf_bigstep.jpg.jpg
The issue is, path has app_imageDir
but you are using imageDir
so change it. 问题是,路径具有
app_imageDir
但是您正在使用imageDir
因此请对其进行更改。
Note : extra .jpg
, probably chattRitem.itemImageFileName
already has .jpg
extension so no need of it 注意:额外的
.jpg
,可能是chattRitem.itemImageFileName
已经具有.jpg
扩展名,因此不需要它
I needed the context. 我需要上下文。 That was my issue.
那是我的问题。 Here is my new code:
这是我的新代码:
//loading image here
val context = itemView.context
val path: String = context.filesDir.absolutePath
val file = File(path, chattRItem.itemImageFileName )
Picasso.get().load(file).into(itemView.imageView_people)
}
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.