Store accelerometer data in a memory and read later

I assume you are using a UNO
looks as though you are using the String class - this is not recommended on low power low SRAM micros such as the UNO - the memory can become fragmented leading to unpredictable problems and possible system crash
use C type char arrays

also as @jremington suggests write a simple test program then once it is working worry about writing complex data structures