【发布时间】:2019-09-12 03:29:24
【问题描述】:
可以建议任何解决方案或代码示例来从 React Native 中的内容提供者 android 获取数据。 目前,我使用“react-native-fs”,但它无法从内容提供者那里获取数据,或者我可能对这个库有误。 我的代码
const uriContent = 'content://xxx.provider/info_all'
const existFile = await RNFS.exists(uriContent)
if (existFile) {
const fileContent = await RNFS.readFile(uriContent, 'utf8')
try {
const newData = JSON.parse(fileContent)
// console.log('GOT RESULT UUID', newData.uuid);
if (newData !== undefined && newData !== null &&
newData.uuid !== undefined && newData.uuid !== null && newData.uuid.length > 0) {
return newData.uuid
} else {
return ''
}
} catch (error) {
console.log(error.message, error.code)
return ''
}
} else {
return ''
}
【问题讨论】:
标签: react-native