2015-03-08 58 views
0

由於Android中的SugarORM,我在SQLite數據庫中創建表。Android - SugarORM - 從表中選擇對象

public class ProjectPhotoData extends SugarRecord<ProjectPhotoData> { 


public boolean isSent; 
public int pictureType; 

public ProjectPhotoData() { 

} 


public ProjectPhotoData(boolean isSent, int pictureType) { 


    this.isSent = isSent; 
    this.pictureType = pictureType; 

} 

但我不知道如何從這個表中檢索對象?

比如我保存在這個表對象:

ProjectPhotoData photoData = new ProjectPhotoData(false,5); 
    photoData.save(); 
    ProjectPhotoData photoDataSecond = new ProjectPhotoData(true,3); 
    photoDataSecond.save(); 

而如何以檢索對象,其中pictureType是5?

任何想法?

回答

1

您可以使用查詢構建器來查詢數據。這裏有一些示例http://satyan.github.io/sugar/query.html

ProjectPhotoData.find(ProjectPhotoData.class, "picture_type = ?", "5"); 
+0

如何查找picture_type == 5或picture_type == 3 – iamanyone 2015-05-14 09:57:47