"",
"",
""
"app-plus" : {
"permissions": {
"plus": {
"description": "访问系统文件",
"features": ["io"]
}
},
}
方式一:
//读取到app下的_doc下的目录 然后取到sqlists.json文件 没有create:true这个则是创建
plus.io.resolveLocalFileSystemURL("_doc/",(entry)=> {
entry.getFile("sqlists.json",{create:true,exclusive:false},function(file){
const fileReader = new plus.io.FileReader()
fileReader.readAsText(file, 'utf-8')
console.log(file.fullPath)
fileReader.onloadend = (evt) => {
console.log(JSON.parse(evt.target.result))
_this.dataList = JSON.parse(evt.target.result).createTable
_this.insertTable = JSON.parse(evt.target.result).insertTable
console.log(JSON.parse(evt.target.result))
console.log(_this.insertTable)
// 调用其他方法进行数据操作
_this.createTable()
}
//
})
}, (err) => {
console.log("发生了错误", err)
})
方式二:
//app安卓的情况 在这个位置的目录 然后取到sqlists.json文件 然后同样的道理进行读取
plus.io.resolveLocalFileSystemURL("/storage/emulated/0/Android/data/uni.demo.test/apps/__UNI__8D07247/doc/sqlists.json", (entry) => {
entry.file((file) => {
const fileReader = new plus.io.FileReader()
fileReader.readAsText(file, 'utf-8')
console.log(file.fullPath)
fileReader.onloadend = (evt) => {
console.log(JSON.parse(evt.target.result))
_this.dataList = JSON.parse(evt.target.result).createTable
_this.insertTable = JSON.parse(evt.target.result).insertTable
console.log(JSON.parse(evt.target.result))
console.log(_this.insertTable)
// 调用其他方法进行数据操作
_this.createTable()
}
//
})
}, (err) => {
console.log("发生了错误", err)
})
plus.io.resolveLocalFileSystemURL('_www/static/_db/init.db',function(entry){
plus.io.resolveLocalFileSystemURL("_doc",function(root){
entry.copyTo(root ,'test.db' ,function(){
console.log("拷贝成功");
},function(){
console.log("拷贝失败");
})
})
});
{
"createTable": [
"CREATE TABLE if not exists \"app_dept\" (\"id\" INTEGER PRIMARY KEY AUTOINCREMENT ,\"pid\" INTEGER ,\"dept_name\" TEXT ,\"dept_brief_name\" TEXT,\"dept_type\" TEXT)",
"CREATE TABLE if not exists \"app_org_user\" (\"user_id\" INTEGER PRIMARY KEY AUTOINCREMENT ,\"dept_id\" INTEGER ,\"user_name\" TEXT ,\"sex\" TEXT ,\"birthday\" TEXT ,\"img\" TEXT,\"mz\" TEXT ,\"native_place\" TEXT ,\"birth_place\" TEXT ,\"join_party_time\" TEXT ,\"start_work\" TEXT ,\"health_status\" TEXT ,\"technical_position\" TEXT ,\"speciality\" TEXT,\"full_time_edu\" TEXT,\"full_time_degree\" TEXT,\"full_time_school\" TEXT,\"full_time_yuan\" TEXT,\"full_time_major\" TEXT,\"job_time_edu\" TEXT,\"job_time_degree\" TEXT,\"job_time_school\" TEXT,\"job_time_yuan\" TEXT,\"job_time_major\" TEXT,\"user_level\" TEXT,\"now_posts\" TEXT,\"resumes\" TEXT,\"familys\" TEXT,\"ext01\" TEXT,\"ext02\" TEXT,\"ext03\" TEXT,\"ext04\" TEXT,\"ext05\" TEXT)",
"CREATE TABLE if not exists \"app_org_user_post\" (\"id\" INTEGER PRIMARY KEY AUTOINCREMENT ,\"user_id\" INTEGER ,\"user_name\" TEXT ,\"post_dept_name\" TEXT,\"jobs_work\" TEXT,\"re_start_time\" TEXT,\"test_time\" TEXT,\"end_time\" TEXT ,\"real_end_time\" TEXT ,\"job_status\" TEXT ,\"reasons\" TEXT ,\"create_time\" TEXT )",
"CREATE TABLE if not exists \"app_org_user_resumes\" (\"id\" INTEGER PRIMARY KEY AUTOINCREMENT ,\"user_id\" INTEGER ,\"user_name\" TEXT ,\"title\" TEXT,\"start_time\" TEXT,\"end_time\" TEXT,\"create_time\" TEXT)",
],
"insertTable": [
"insert OR REPLACE INTO 'app_dept' (id,pid,dept_name,dept_brief_name,dept_type) values(\"311\",\"0\",\"山河大学\",\"山河大学\",\"0\")",
"insert OR REPLACE INTO 'app_dept' (id,pid,dept_name,dept_brief_name,dept_type) values(\"439\",\"311\",\"领导班子\",\"院领导\",\"0\")",
"insert OR REPLACE INTO 'app_dept' (id,pid,dept_name,dept_brief_name,dept_type) values(\"440\",\"311\",\"党政办公室\",\"党政办公室\",\"0\")",
"insert OR REPLACE INTO 'app_dept' (id,pid,dept_name,dept_brief_name,dept_type) values(\"442\",\"311\",\"党委组织部 机关党总支 党校\",\"党委组织部 机关党总支 党校\",\"0\")",
]
}