我在WINDOWS设备中有共享文件夹,我可以从任何其他windows设备访问,但我需要通过Cordova开发的android应用程序访问该文件夹和(读/写)其内容,特别是sqlite文件。有没有什么插件可以帮上忙??我尝试了cordova-plugin-file和cordova-sqlite-evcore-extbuild-free,但仍然找不到任何帮助
这是我在Android文件夹中读写内部数据库SQlite的代码
document.addEventListener('deviceready', function() {
var dirr = 'file:///storage/emulated/0/Android';
//var dirr = '//192.168.1.29/shrd'; // That What I need
window.resolveLocalFileSystemURL(dirr, function(externalDataDirectoryEntry) {
var db = window.sqlitePlugin.openDatabase({name: 'shared.db', androidDatabaseLocation: externalDataDirectoryEntry.toURL()});
db.transaction(function(tx) {
tx.executeSql('CREATE TABLE IF NOT EXISTS MyTable (data)');
tx.executeSql('INSERT INTO MyTable VALUES (?)', ['test-value']);
}, function(error) {
console.log('Populate database error: ' + error.message);
}, function() {
db.transaction(function(tx) {
tx.executeSql('SELECT data from MyTable', [], function(tx_ignored, resultSet) {
console.log('Record count: ' + resultSet.rows.length);
for (var i=0; i < resultSet.rows.length; ++i)
console.log('index: ' + i + ' value: ' + resultSet.rows.item(i).data);
});
}, function(error) {
console.log('Populate database error: ' + error.message);
});
});
});
有什么帮助吗?
发布于 2021-11-22 14:39:51
如果您的应用程序仅适用于安卓系统,那么您可以尝试使用cordova-plugin-samba并使用samba通过smb://192.168.1.29/shrd
连接到网络
https://stackoverflow.com/questions/70064985
复制相似问题