android - How to get total video & image size from external SD card -


I am trying to calculate the total memory size (video and image) from an external SD card. For example, a method is mediastore.audio.media.gate contactUrifpath (string path) . From where I can get the URI and calculate size audio files. Passing ..

  Private long mill media (Uri Yuri) {Log. ("URI", "Yuri +"); String [] project = {MediaStore.MediaColumns.SIZE}; Cursor cursor = ((activity) reference) .Get content resolver (). Query (Yuri, Prose, Blank, Blank, Blank); Long size = DirectoryMediaSize.getMediaSize (cursor); Cursor.close (); Return size; }   

There is no such way as MediaStore.Video.Media.getContentUriForPath () . So how can I calculate the size for (in the video & image) ???

itemprop = "text">

Try the following code: -

  URI selected IMAGEURI = data.getData (); File image file = new file (getRealPathFromURI (selected imageURI)); Long check = ((imageFile.length () / 1024); If (Check & lt; 5000) {// less than 5 MB} else {// greater than 5 MB}   

function getRealPathFromURI

  string mill rialpathformu (Uri materialurai) {string result; Cursor cursor = getContentResolver (). Query (contentURI, empty, empty, empty, empty); If (cursor == zero) {// Source dropbox or other similar local file path is result = contentURI.getPath (); } Else {cursor.moveToFirst (); Int idx = cursor.getColumnIndex (MediaStore.Images.ImageColumns.DATA); Result = cursor.juststring (idx); Cursor.close (); } Return results; }    

Comments

Popular posts from this blog

Pass DB Connection parameters to a Kettle a.k.a PDI table Input step dynamically from Excel -

multithreading - PhantomJS-Node in a for Loop -

c++ - MATLAB .m file to .mex file using Matlab Compiler -