0

I am developing an android game, in which i have some trains moving on track. In this game, i want to provide option to add some more special trains when user acquired a certain number of points. But am not getting how can i do it, while in project development am putting trains images in drawable folder, and using them as resources in my code. Now i want to put these new trains images on to server, and if user scored some certain score than only give him option to purchase new trains using those score. but how can i update .apk file for these new trains for that particular phone user...I hope you are getting my point as i need to make changes in code.

or there is any other way of doing it.

Please suggest.

Romi
  • 4,833
  • 28
  • 81
  • 113

2 Answers2

0

there r many similar questons on SO. Please look into my answer here in this Dynamically populate Android ImageView with outside resources

Community
  • 1
  • 1
Seshu Vinay
  • 13,560
  • 9
  • 60
  • 109
  • can i add iamges from remote server to loacal sqlite and use them as resources , without updating .apk file, i mean images should come from lcal database randomly, as they are added. – Romi Dec 22 '11 at 12:39
  • u can even use directly from server with out saving in database – Seshu Vinay Dec 22 '11 at 12:40
  • actually i want some train images only available to user if he scored a certain number of poitns, so i want to update my local db for those images, but the thing is am making an object using these images and what i want is images should come randomely from DB, my question is what field i should use to get random images – Romi Dec 22 '11 at 12:47
  • use java.Math.random() to get random image from database – Seshu Vinay Dec 22 '11 at 12:50
  • this java function will generate a random number, with in a certain range we specify, and if suppose we store images by id, than id might not be with in that range – Romi Dec 22 '11 at 12:55
  • @Romi but no. of images are limited – Seshu Vinay Dec 22 '11 at 13:48
  • save the ids in an array and give the element of the array using a random variable(index of array) – Seshu Vinay Dec 22 '11 at 13:48
  • yes exactly images are limited, suppose i have 10 images, id from 1 to 10, and generated random num is 54, than?? – Romi Dec 22 '11 at 14:08
  • i am asking u to generate random variable btw 1 to 10. and match the related id – Seshu Vinay Dec 22 '11 at 14:22
  • for eg. this is array {R.id.image1,R.id.image2,...} so if the random variable is 2 then image is R.id.image2... got it? – Seshu Vinay Dec 22 '11 at 14:24
  • yes that i understand, but some times images may be more than ten nd some time less than 10 – Romi Dec 23 '11 at 05:15
  • yea but if u keep them in an array... u should be able to know the lengh of array.. so keep the range of random number to that length – Seshu Vinay Dec 23 '11 at 05:48
-1

I think the apk cant be updated once it is installed, you can have something like a free version and pro version as per the below question on SO:

Maintain pro and free version in Android

Try this:

http://en.androidwiki.com/wiki/Loading_images_from_a_remote_server

Community
  • 1
  • 1