2011-07-25 36 views
0

我试图用于存储数据的Android Application类(MyApplication.java)在字符串的一些ArrayList S和int小号应用程序类可用于存储数据? (持久性数据)

我想这些数据得到真实永远保存,如数据库,但不使用数据库,以简化我的应用程序。

当我退出应用程序时,仅当应用程序的进程仍处于后台时,才会存储数据。但是,如果我杀了应用程序的进程,MyApplication.java类中存储的数据将被删除。

有办法解决这个问题吗?

代码恢复:

public class MyApplication extends Application { 
    public static String LeagueTable[][] = new String[21][8]; 
    //COLUMNAS MATRIZ: 
    //0  /1 /2 /3 /4 /5 /6 /7 
    //nombre/P.J./P.G./P.E./P.P./G.F./G.C./Pts 

    public static League LFP = new League(); 
    public static Category Primera = new Category(20); 
    public static int NEQUIPOS=20; 
    public static int[][] matriz= new int[NEQUIPOS+1][NEQUIPOS+1]; //esta es la matriz de emparejamientos, representa el calendario 
    public static int PlayerTeamID; 
    public static boolean ExistingSaveGame=false;//esto es true cuando existe una partida guardada 

    //variables candidatas a poner dentro de una de las clases del modelo, como season por ejemplo 
    public static int RoundNumber; //jornada actual 
    public static boolean SeasonOver=false;//true cuando la temporada ha terminado 

    public void onCreate() { 
     super.onCreate(); 
    } 

    public void onTerminate() { 
     super.onTerminate(); 
    } 

"and a lot of functions that works with the static variables" 

回答

2

不,不可能。如果你不把数据存储在存储器中(这不需要是数据库,可能是一个平面文件或其他),那么它不是持久的。

+0

有一种方法来存储变量格式? (arraylist,array [] []等.. ??????我需要做它没有数据库 – NullPointerException

+0

看看[ObjectInputStream](http://developer.android.com/reference/java/io/ ObjectInputStream.html)和[ObjectOutputStream](http://developer.android.com/reference/java/io/ObjectOutputStream.html)。只要您保存的所有内容都可以被序列化,这些工作就会起作用。 –

相关问题