I really have to use another thread to read and write a sharedPreferences
file?
I'm storing an integer array
in sharedPreferences
file, I convert it in string to store there, ok, this array corresponds to the itens of a gridView, then I have to read it on onCreate()
and write it on onDestroy()
, the problem is I'm calling an asyncTask
on onCreate() and this is causing a lot of problems... the main one is that the onCreate() is been called many times (every time that other activity came in front mine, it is destroyed and restarted...), I found out in here that a kind bug occurs when other thead is called on onCreate(), then I had to save some things on onSaveInstanceState()
, but this only resolved my problem in part. I already tested do not use other thread and read and write the file directly on UI thread, and this worked nicely, but I always heard I have to use other thread to any kind of I/O
... then I'm in doubt...
After all, I can or I can't read and write a sharedPreferences file without call other thread?
Thx