0

I am storing byte array from JSONObject. this byte array is a file data.

JSONObject is like this:

ex: {"FileData":[23,21,2,5]}

JSONObject jsonObject = new JSONObject(apidata);
String imagedata = jsonObject.getJSONArray("FileData").toString();
Gson gson = new Gson();
byte[] filebytes = gson.fromJson(imagedata, byte[].class);

Its working fine for small byte array. but if "FileData" is big array then Out Of Memory Error at storing string variable. Please help me how to overcome this problem.

  • Not the best way to transfer a file. Can you change the API? That would be the easiest solution. – Henry Aug 19 '13 at 07:28

3 Answers3

0

may this thread could help you. OutOfMemoryException is thrown as the memory of the JVM is full. So you have to increase your memory size.

Cheers

Community
  • 1
  • 1
ZeusNet
  • 710
  • 10
  • 25
0
  1. I doubt your JVM running in eclipse is out of memory.i think you must increase size for JVM.
  2. To change the VM for Eclipse you can change the amount of the MV from Windows> Preferences> Java> Installed JREs from there select the JRE and click edit
  3. write in the Default VM Arguments: to -Xmx1024M or any other amount of memory.
KOTIOS
  • 10,974
  • 3
  • 34
  • 61
0

You can try android:largeHeap="true" in your application tag at manifest

Hope it helps you

Sanket Shah
  • 4,331
  • 3
  • 18
  • 37