2011-07-25 5 views
0
私は、文字列の一部 ArrayList秒でデータを格納するためのAndroid Applicationクラス(MyApplication.java)を使用しようとしている

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、配列[] []など。??????データベースなしでそれを行う必要があります – NullPointerException

+0

[ObjectInputStream](http://developer.android.com/reference/java/io/)を見てください。 ObjectInputStream.html)と[ObjectOutputStream](http://developer.android.com/reference/java/io/ObjectOutputStream.html)。これらは、保存しているものすべてをシリアル化できる限り機能します。 –

関連する問題