我正在尝试使用Android中的房间持久性库构建一个记事应用程序。
当我想保存带有标题,描述和时间戳的新便笺时,它是可行的,但是我需要从图库中上传图像,并将带有标题,描述和时间戳的图像另存为新便笺。
有人可以帮助我吗?这是我尝试过的:
@Entity(tableName = "notes")
public class Note implements Parcelable
{
@PrimaryKey(autoGenerate = true)
private int id;
@ColumnInfo(name = "title")
private String title;
@ColumnInfo(name = "content")
private String content;
@ColumnInfo(name = "timestamp")
private String timestamp;
@Ignore
public Note()
{
}
public Note(int id, String title, String content, String timestamp)
{
this.id = id;
this.title = title;
this.content = content;
this.timestamp = timestamp;
}
protected Note(Parcel in)
{
id = in.readInt();
title = in.readString();
content = in.readString();
timestamp = in.readString();
}
public static final Creator<Note> CREATOR = new Creator<Note>()
{
@Override
public Note createFromParcel(Parcel in)
{
return new Note(in);
}
@Override
public Note[] newArray(int size)
{
return new Note[size];
}
};
public int getId()
{
return id;
}
public void setId(int id)
{
this.id = id;
}
public String getTitle()
{
return title;
}
public void setTitle(String title)
{
this.title = title;
}
public String getContent() {
return content;
}
public void setContent(String content) {
this.content = content;
}
public String getTimestamp()
{
return timestamp;
}
public void setTimestamp(String timestamp)
{
this.timestamp = timestamp;
}
@Override
public String toString()
{
return "Note{" +
"id=" + id +
", title='" + title + '\'' +
", content='" + content + '\'' +
", timestamp='" + timestamp + '\'' +
'}';
}
@Override
public int describeContents()
{
return 0;
}
@Override
public void writeToParcel(Parcel dest, int flags)
{
dest.writeInt(id);
dest.writeString(title);
dest.writeString(content);
dest.writeString(timestamp);
}
}