Write data to file in android internal memory

1

I need to write a set of variables:

int var1,var2,var3
var4=new int[10], var5=new int[10], var6=new int[10]
var7=new int[5][3],var8=new int[5][3]

My goal was to record them all in order and then read them all in the same order. For the other posts I saw, to write to internal memory I have to use openFileOutput() but I did not find any examples that explained how to pass array´s , arrays bidimensionais . Can someone tell me a way to solve this?

    
asked by anonymous 20.12.2016 / 20:45

1 answer

2

Well, I do not know if I understood correctly what you need to do. But come on, what I understood is that you need to store values in the android memory, but does it have to be in a specific file? Otherwise, you can only use SharedPreferences, which serves exactly to save small amounts of data, giving each one a key and adding its value. Example: link

But if your plan is even save to file:

String FILENAME = "hello_file";
String string = "hello world!";

FileOutputStream fos = openFileOutput(FILENAME, Context.MODE_PRIVATE);
fos.write(string.getBytes());
fos.close();

In doubt, take a look here at Storage Methods:

link

    
21.12.2016 / 00:40