简体   繁体   中英

How to access this internal storage directory?

I need to access this internal storage folder: /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. 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

The issue is, path has app_imageDir but you are using imageDir so change it.

Note : extra .jpg , probably chattRitem.itemImageFileName already has .jpg extension so no need of it

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)
        }

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM