我想在android中保存新闻文章。 问题是,它们包含随机出现的文本和图像。所以我真的不能使用SQL数据库。什么是最有效的方法。我应该使用NoSQL数据库吗?如果是,那么哪一个?
答案 0 :(得分:0)
使用XML文件。 根据您的新闻创建XML,如
class Sites extends React.Component {
constructor (props) {
super(props);
this.handleUpdate = this.handleUpdate.bind(this);
this.handleDelete = this.handleDelete.bind(this);
this.state = {records: this.props.records};
}
handleUpdate (record) {
let records = this.state.records;
let index = records.map((x) => {return x.id}).indexOf(record.id);
records.splice(index, 1, record);
this.setState({records: records}); # this doesn't re-render the results
}
handleDelete (record) {
let records = this.state.records;
let index = records.map((x) => {return x.id}).indexOf(record.id);
records.splice(index, 1);
this.setState({records: records}); # this re-renders the results
}
render () {
let records = this.state.records.map((record) => {
return (
<Record record={record} key={record.id} handleUpdateRecord={this.handleUpdate} handleDeleteRecord={this.handleDelete}/>
);
});
return (
<div className="col-sm-9">
<table className="table table-striped">
<thead>
<tr>
<th>Name</th>
<th>City</th>
<th>State</th>
<th>Actions</th>
</tr>
</thead>
<tbody>
{records}
</tbody>
</table>
</div>
);
}
}
使用XML解析器将XML内容解析为视图。