I got the thumbnail path of videos using CursorLoader
. MediaStore is giving me the thumbnail path. Now When I check for if the thumbnail path exists or not, it's giving me that file not exists
.
I've found thumbnail path using
Cursor c = new CursorLoader(getApplicationContext(), MediaStore.Video.Thumbnails.getContentUri("external"), project, selection, selectionArgs, null).loadInBackground();
while(c.moveToNext()) {
//Toast.makeText(getApplicationContext(), c.getString(1),Toast.LENGTH_LONG).show();
paths=c.getString(1);
}
Toasts showing a path like
/storage/emulated/0/DCIM/.thumbnails/1411810114902.jpg
So I decided to check if file exists before doing something with it.
File file = new File(paths);
if (file.exists())
{
Toast.makeText(getApplicationContext(), "YES",Toast.LENGTH_LONG).show();
}
else
{
Toast.makeText(getApplicationContext(), "NO",Toast.LENGTH_LONG).show();
}
Surprisingly it's showing NO
how! What mediastore gave me?? My main intention is to manipulate or convert the thumbnail image into base64 string. But decodeFile
method was giving File not exists
error so I tried to check the existence of the file.
Why is this giving me error like file not exists when filepath is given by the mediaStore. What's going on? What I'm missing? What's the way to manipulate/access thumbnail image?
I came across the same issue few days ago. The reason is due to some internal memory management process, sometimes it store images either in /storage/emulated/0/DCIM
or /storage/emulated/1/DCIM
.
To deal with this, its always recommended that Create your new folder for saving newly captured image from camera & access it from that folder.
Also, Check it on real device it may because there is no sd card for emulator & So it gets confused where to store if internal memory gets full so it jumps to sd card dcim folder.
Collected from the Internet
Please contact [email protected] to delete if infringement.
Comments