MediaStore returned thumbnail path but File object giving file not exist - Android

AtanuCSE

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?

VVB

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.

edited at
0

Comments

0 comments
Login to comment

Related

From Dev

How to create a video thumbnail from a video file path in Android?

From Dev

Getting audio file path or URI from mediastore

From Dev

Android - Thumbnail from video file

From Dev

Python giving FileNotFoundError for file name returned by os.listdir

From Dev

Android new File(path)

From Dev

Android: Media file Path

From Dev

Android Device File Path

From Dev

Android application file path

From Dev

Android file path error

From Dev

How to check if path or file exist in Scala

From Dev

How to create a Path and a File that does not Exist in Java

From Dev

Bash + check for file exist with a path home ~

From Dev

How to check if path or file exist in Scala

From Dev

Write to a file whose path does not exist yet

From Dev

Bash + check for file exist with a path home ~

From Dev

extract part of the path to file or "/" if it doesn't exist

From Dev

chown: -R: A file or directory in the path does not exist

From Dev

Check if file already exist in the same path

From Dev

file.getName() on a File object created in Android from a file path generated in Java produces strange results

From Dev

To set thumbnail to a video file

From Dev

Retrieve thumbnail for a given file

From Dev

Java path object Vs File

From Dev

Create a file object from a path

From Dev

Add a file name to a Path object

From Dev

Absolute Path of a Local File Object

From Dev

Extract Thumbnail for specific second from MP4 file in Android

From Dev

Full path of HttpPostedFileBase is giving error with webclient upload file

From Dev

os.path.getsize() is not giving the true size of the file on OSX

From Dev

Android: Thumbnail stored in DB is returned null

Related Related

HotTag

Archive