Generation
For generating a world, I recommend the Perlin noise algorithm. I'm sure there are dozens of good tutorials and explanations elsewhere on the internet, so I won't go into detail here. There is a less well-known noise generation algorithm, Simplex noise, that is better than Perlin noise, but you are less likely to find a tutorial about that for Android. The advantage Perlin noise has over many other generation methods is that each column is generated independently of the others, so you can generate the column only when you need it.
Storing
So you have used your generation algorithm to make a world like this (except a lot bigger than 10x20):
██▀▀▀▀▀████████▀▀▀██
▀ ▀▀
▄███████▄▄▄
█▄▄▄████████████████
Look at the first column:
█
▀
█
By storing it as a basic image, you would need a color for each of the ten pixels. Assuming the image format doesn't support an alpha channel, a color is 24 bits, so a list of ten colors is 240 bits.
(0, 0, 0)
(0, 0, 0)
(0, 0, 0)
(255,255,255)
(255,255,255)
(255,255,255)
(255,255,255)
(255,255,255)
(0, 0, 0)
(0, 0, 0)
Expand that to 1000 pixels tall, and you're using 24,000 bits per column. There are 20,000 columns, so that's 480,000,000 bits or 60,000,000 bytes. You were trying to load about 57 megabytes at once.
Now, what if you just stored it as a bunch of bits, one bit per pixel? Ten pixels would be 10 bits.
1110000011
Expand that out to the entire map and you get 20,000,000 bits or 2,500,000 bytes.
But you can still store it with far less memory. There are only two places where it changes between 1s and 0s, so you could store that like this:
3, 8
If you give each number 10 bits to be able to store values up to 1,000, that's 20 bits per column. Multiply that for all the columns, and that's only 400,000 bits or 50,000 bytes to store the entire map.
However, you don't need to store the entire map in RAM; you can load/generate only the part of the map you need a second before you need it. Assuming you have a 1000 pixel wide screen and you pre-load/-generate another 1000, that's 2000 columns loaded at once. 2,000 x 20 bits is 40,000 bits, or only 5,000 bytes stored on RAM at once. That is less than a ten-thousandth of what you were trying to store originally.
Collision detection
To detect if the player has collided with a wall, look at it column by column. Take the leftmost column that the player is still a part of, i.e. this one:
↓
██▀█▀▀▀████████▀▀▀██
▀ ▀▀
▄▄
▀▀ ▄███████▄▄▄
█▄▄▄████████████████
Check whether the top pixel of the player:
▀
→▄
▀
▄
is above the first value stored in the map, which would be about here:
→▀
▄
▀
▄
If it is (which it isn't in this case), you have a collision. Next, do the same for the bottom:
▀
▄
→▀
→▄
No collision there, either. Do the same for the rest of the columns the player is a part of. If the player's top pixel is ever above the first value for that column or the bottom pixel is ever below the second value, you know you have a collision.