1

I am using certain bitmaps in my app which I am storing in the Drawable folder. When the user uses these bitmap in some kind, I want those bitmaps to be deleted. How shall I Implement this without using any kind of databases?

Edit: I came to know that res/drawable is Read only. Then is there a technique to save the bitmaps anywhere else and then delete them. Can SQLite database be used for this purpose? If Yes, some code would be very helpful.

Brian Tompsett - 汤莱恩
  • 5,753
  • 72
  • 57
  • 129

2 Answers2

2

You can not delete images from Drawable folder. Because android application apk file is read only, so from any directory of project structure of .apk file you are only able read available files but can not delete or modify these files.

user370305
  • 108,599
  • 23
  • 164
  • 151
  • Is there other way to save these bitmaps anywhere and then delete them? Can SQLite be used to do this and how? –  Mar 06 '15 at 20:40
  • @coder12345 - The only way is, you have to download these Bitmaps from your server to your application on application installation, Store in application's internal storage (storage options may be various) and then delete when not useful. This is the only way. But from application apk file directory you can't. – user370305 Mar 06 '15 at 20:43
  • This means that if I have some images preloaded in my app , I cannot delete them.Am I Right? btw thanks! –  Mar 06 '15 at 20:51
  • Yes, You are right, Only if you are going to update your application version. (But this apply to all application weather they used your bitmaps or not, so not works in your case) – user370305 Mar 06 '15 at 20:54
0

The Drawable folder is a Resource of your application. I can't think of any situation where you'll ever need to remove parts of your application, unless you are upgrading versions, in which case you remove and add new stuff yourself and then release some new version of your app. Therefore, your apk file is read only.

If you need to handle files in your application, you have some storage options you could take a look:

http://developer.android.com/guide/topics/data/data-storage.html

vinitius
  • 3,212
  • 2
  • 17
  • 22