Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Opening database on sd card tries to open on internal storage #38

Open
stihl-sicher opened this issue May 7, 2018 · 2 comments
Open

Comments

@stihl-sicher
Copy link

Hi,

I want to open an MBTiles-File (which is an sqlite database) from the sd card. I have got the path and it can be resolved by the File-Plugin. So I try to open the database using the parameter "androidDatabaseLocation" as described. This results in opening the database from internal storage.
Opening files from any location in internal storage works perfect that way. But trying to read from sd card replaced the sd card with internal storage.
Does anyone have an idea for me?
Actually testing on Samsung Galaxy Tab Active2, Android 7.1. External write permission is set in the manifest file.

@brodycj
Copy link
Contributor

brodycj commented May 10, 2018

Can you get the database file statistics from File plugin?

@tnicolazzi-gis
Copy link

Hi,

I think I have same problem, when I try to open database on SDCard from here
file:///storage/emulated/0/Android/data/<...>/files/myDb

And I still doesn't understand why it creates an empty database on local storage,
/Android/data/<..>/files/myDb

Here is my JS code, nothing fancy :

window.resolveLocalFileSystemURL(
            cordova.file.externalDataDirectory,
            function (externalDataDirectoryEntry) {
                console.log(externalDataDirectoryEntry.toURL())
// return : "file:///storage/emulated/0/Android/data/<...>/files/"
                var db = window.sqlitePlugin.openDatabase({
                    name: db_name,
                    androidDatabaseLocation: externalDataDirectoryEntry.toURL(),
                });
(...)

If I read file with

window.resolveLocalFileSystemURL(cordova.file.externalDataDirectory + db_name (...)

I get a clean fileEntry :

fullPath:"/myDb"
isDirectory:false
isFile:true
name:"myDb"
nativeURL:"file:///storage/emulated/0/Android/data/<...>/files/myDb"

If I put my database directly in the internal storage at /Android/data/<..>/files/myDb, everthing working fine ... Is there something I missing ?

Thanks for your help !

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants