Write to /res/drawable/ on the fly? - android

My widget reads an image from /res/drawable/.
I would like to be able to change the image and write it back out to the /res/drawable/ structure.
Is this possible?

Everything in the apk will be read only.
And it's even better: android doesn't extract the apk when you install a program, so the size consumed is kept to minimal.

You cannot write to res/drawable.

Nope. But you can change your program to use alternate forms of storage.
http://developer.android.com/guide/topics/data/data-storage.html

Related

Insert a picture in an Android Application

I want to insert a picture from my filesystem to a new Android Project.
What code do I have to write and especially where?
That means in src/package/main.java and or in res/layout/activity_main.xml???
Put it into res/drawable.
Anyway, go for this piece of documentation. It is worth the time:
http://developer.android.com/guide/practices/screens_support.html

Can I change a string in the strings resource file to one from array in an activity?

Been having a little bit of trouble with this. Googled about and I can't really find anything. Saw a few things about setting text but I don't think that affects the string resource file or at least I can't make it affect the resource file. Help please!
No, you can't modify apk at the runtime. If you don't own source code, you can pull apk file to the computer and decompile it by using APKTool, for example. If you are working with data you get from internet/user, it should be kept inside DBs, files, whatever. In other words in internal or external storage. Please take a look on storage options you can use http://developer.android.com/guide/topics/data/data-storage.html

Is there such thing as system images available in Android?

I'd like to use basic images like the ones in the menu of the alarm application. Are these images integrated in the Android SDK ? I didn't find any way to access them.
If not, do you know a good free library ?
Thanks in advance,
Regards,
C.Hamel
http://www.darshancomputing.com/android/1.5-drawables.html is your answer
and than you access like this android:icon="#android:drawable/ic_menu_delete"
if you want to use image of android system then you can use that all image which are in android's system..
you just need to write android.R.drawable and you will get all image ...
android.R.drawable.btn_dialog
Look in your android-sdk folder, you will find folders for each version of android including all the system images. You can copy the images you need to your own ressource folder and use them from there.

Externally download the file Strings.xml?

Hey, I have a lot of strings data, so I put them into Strings.xml..
The problem is that String.xml now is 5 mb big! So the .apk becomes big.. If I make on the first lunch of my app download the Strings.xml from a server, is it possible to replace a blank one that I put into the .apk with the one that I download after the app installation? Or is it bad to have the Strings.xml so big?
Resources are read-only, so you can't replace them.
If you're not using the localization features (-en, -it, -de ...) and you can make your app download only the strings you need (provided you don't need always all of them), I would do that if it's worth it.
However, even if 5mb for a text file is a lot, I don't know if there are actual drawbacks, and in the end it will get compressed when in the apk.
Short answer: you can't replace a file which is embedded into the apk,
also note that during the building stage, each xmls are converted into a
binary representation.
Since I don't know nothing about your app I can't tell if is bad to have
a so big string.xml. maybe I'll take a look at the performance and at the
memory consumption.

read an image I just wrote in android

So, largely for debugging purposes, I want to be able to write an image at arbitrary points in my code, and look at it later. I figured this would be easiest if I just wrote a my bitmap to a file and read it back later, but I cannot seem to figure out where to find the file after I write it, or how to open an image that is not in res/drawable with a corresponding handle in R.
You can use openFileOutput() and openFileInput(). These pull up data streams that point to files in your app's directory, and are (as far as I know), the suggested way to handle files that your app makes.

Categories

Resources