CRey
CRey

Reputation: 1160

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

Upvotes: 1

Views: 2854

Answers (2)

CRey
CRey

Reputation: 1160

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

Upvotes: 1

Pavneet_Singh
Pavneet_Singh

Reputation: 37414

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

Upvotes: 3

Related Questions