簡體   English   中英

Android序列化

[英]Android Serialization

我有這四個班

public class Ingredient implements Serializable{

    private String mIngredientName;
    private double mQuantity;
    private String mUnits;

    // Constructors and methods here....

}

public class Step implements Serializable{

    private int mStepNumber;
    private String mDescription;

    // Constructors and methods here....
}

public class Category implements Serializable{

    private String mCategoryName;

    // Constructors and methods here....

}

public class Recipe implements Serializable{

    private String mTitle;
    private String mPhotoPath;
    private List<Ingredient> mIngredients;
    private List<Step> mSteps;
    private int mRating;
    private List<Category> mCategories;

    // Constructors and methods here....

   List<Recipe> recipes = new ArrayList<Recipe>(); // I want to save this.        Assuming that the object actually contains Recipe objects
}

我想序列化食譜對象,因為我不想使用SQL數據庫,這對我來說太過分了。 其他三個對象是否應該可序列化才能正常工作?

是的,如果您要序列化對象,其其他類必須實現serializable :)。 數據庫很有趣,應該再花些時間。

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM