I developed an Android application via cordova
which running inside a webview. How can I make the app use persistent storage
in chromium? It only consumes temporary storage
. The reason I need to use persistent storage
is that I can request more spaces. If I use temporary storage
and it runs of out maximum limit, the temporary storage will remove old data on the database.
I run below code in chrome console and it gives me we are using 0 of 0 bytes
which means there is 0 space in persistent storage I can use.
navigator.webkitPersistentStorage.queryUsageAndQuota (
function(usedBytes, grantedBytes) {
console.log('we are using ', usedBytes, ' of ', grantedBytes, 'bytes');
},
function(e) { console.log('Error', e); }
);
Then I run below code to request more storage:
navigator.webkitPersistentStorage.requestQuota (
100 * 1024 * 1024, function(grantedBytes) {
window.requestFileSystem(PERSISTENT, grantedBytes, (d) => console.log(d), e => console.error(e));
}, function(e) { console.log('Error', e); }
);
after that nothing happens and it is still 0 storage space I can use. I wonder how I can use persistent storage in webview. Do I need to specify any permission for that?
The permission for my app is:
<uses-permission android:name="android.permission.WAKE_LOCK" />
<uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE" />
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
<uses-permission android:name="android.permission.ACCESS_WIFI_STATE" />
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
<uses-permission android:name="android.permission.BLUETOOTH" />
<uses-permission android:name="android.permission.BLUETOOTH_ADMIN" />
<uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION" />
<uses-permission android:name="android.permission.GET_TASKS" />
<uses-permission android:name="android.permission.NFC" />
<uses-permission android:name="android.permission.INTERNET" />
I have checked another question Android webview & localStorage but it is quite different with mine. I am asking to grant persistent storage permission for my webview but that question doesn't explain how to use persistent storage
instead it uses temporary storage
which is the default storage in webview.
I have set setDatabaseEnabled(true)
on java code but it doesn't use persistent storage
. In stead, it uses temporary storage
.