5

I am trying to store one video in memory cache, after video is completed it be deleted from cache. And during play back that video file can't be deleted from cache.

Adam Harte
  • 10,369
  • 7
  • 52
  • 85
Naveen
  • 371
  • 3
  • 4
  • 14
  • what are you trying to do? Caching bitamps? – Raghunandan Apr 02 '13 at 10:26
  • By the question number 2, look: http://stackoverflow.com/questions/10977288/clear-application-cache-on-exit-in-android – Castiblanco Apr 02 '13 at 10:27
  • you have to better explain your question. What do you want to cache? bitmap? files? transactions? json? And where do you want to cache it: in RAM memory or permanently? – Budius Apr 02 '13 at 10:31
  • @Raghunandan, I am trying to store one video and i ashould delete that video after completion. – Naveen Apr 02 '13 at 10:32
  • @ Naveen edit youe question and explain clearly what you intend to do an what is the problem you are facing? – Raghunandan Apr 02 '13 at 10:33
  • @Budius, I am trying to store one video and i ashould delete that video after completion. – Naveen Apr 02 '13 at 10:33

2 Answers2

11

Every Android Application has its own limited memory

// Get max available VM memory, exceeding this amount will throw an
// OutOfMemory exception. 
 final int maxMemory = (int) (Runtime.getRuntime().maxMemory() / 1024);

// Use 1/8th of the available memory for this memory cache.
 final int cacheSize = maxMemory / 8;

On a normal device this is a minimum of around 4 MB (32/8) 32 MB allocated per application.

A full screen Grid View filled with images on a device with 800x480 resolution would use around 1.5MB (800*480*4 bytes). 800*480*4 = actual Image size

This would cache a minimum of around 2.5 pages of images in memory.i.e.In Your Grid View only 2.5 images are stored in cache...when you scroll up and down up to 2.5 images,it get the image from cache...when user moved to 3rd or 4th image..the first two images cache is cleared and new download image in cache.

Cache Mechanism is used Mainly for Smooth scrolling of Images in list of Grid View.

Mechanism: In list or Grid view,first images are downloaded from network and stored in cache as user scrolls down..When user Scrolls up the images is fetched from cache if it is available.

Android Uses Two Kind of Mechanism:

1.LRU Cache(Internal application memory used) 2.Disk Cache(sdcard memory used)

Disk Cache code is pulled from Android os. This stores limited amount of data in sdcard. When inserted data exceed,least recently used file is deleted and stores new file.

ex: Facebook Android uses Disk Cache.

Cache Memory is cleared in Application program level or Settings>Manage Applications>App Name.

Every application has its own Cache Memory, one application cannot access the cache memory of other application..

For More information visit:

http://developer.android.com/training/displaying-bitmaps/cache-bitmap.html#disk-cache

user2060635
  • 251
  • 1
  • 5
0

from the comments what you seem to be trying to do is store one file in the permanent memory and delete it afterwards:

so I would suggest you to use the getCacheDir() method to get the location to write the file, then use createTempFile() to create a temporary file and use delete() method whenever you don't need it anymore.

here is a StackOverflow post showing how to do it: https://stackoverflow.com/a/6485850/906362

Community
  • 1
  • 1
Budius
  • 39,391
  • 16
  • 102
  • 144