Tagged: sdcard phonegap
- This topic has 1 reply, 2 voices, and was last updated 8 years, 6 months ago by support-swapna.
-
AuthorPosts
-
KevinRevillParticipantHi Guys,
I have used every piece of sample code under the sun to be found online. but…
cordova.file.externalRootDirectory always points to the root folder of the internal storage and not to the SD card inserted into the android device. I have tried everything. even got another SD card no luck. Below is my config.xml and index.js file, with one of the many failed examples. Please help I really need SD Card access.
using a galaxy ta b2 with android 5.0.2
config.xml
==========
<?xml version=”1.0″ encoding=”UTF-8″?>
<!– config.xml reference: https://build.phonegap.com/docs/config-xml –>
<widget xmlns = “http://www.w3.org/ns/widgets”
xmlns:gap = “http://phonegap.com/ns/1.0”
id = “testone.id”
version = “1.0.0”><name>testone</name>
<description>Blank Application</description>
<author href=”http://myeclipseide.com” email=”[email protected]”>
MyEclipse Phonegap Tools
</author><content src=”index.html” />
<!–
If you do not want any permissions to be added to your app, add the
following tag to your config.xml; you will still have the INTERNET
permission on your app, which PhoneGap requires.
–>
<preference name=”permissions” value=”none”/><!– Customize your app and platform with the preference element. –>
<preference name=”phonegap-version” value=”3.6.3″ /> <!– all: current version of PhoneGap –>
<preference name=”orientation” value=”default” /> <!– all: default means both landscape and portrait are enabled –>
<preference name=”target-device” value=”universal” /> <!– all: possible values handset, tablet, or universal –>
<preference name=”fullscreen” value=”true” /> <!– all: hides the status bar at the top of the screen –>
<preference name=”webviewbounce” value=”true” /> <!– ios: control whether the screen ‘bounces’ when scrolled beyond the top –>
<preference name=”prerendered-icon” value=”true” /> <!– ios: if icon is prerendered, iOS will not apply it’s gloss to the app’s icon on the user’s home screen –>
<preference name=”stay-in-webview” value=”false” /> <!– ios: external links should open in the default browser, ‘true’ would use the webview the app lives in –>
<preference name=”ios-statusbarstyle” value=”black-opaque” /> <!– ios: black-translucent will appear black because the PhoneGap webview doesn’t go beneath the status bar –>
<preference name=”detect-data-types” value=”true” /> <!– ios: controls whether data types (such as phone no. and dates) are automatically turned into links by the system –>
<preference name=”exit-on-suspend” value=”false” /> <!– ios: if set to true, app will terminate when home button is pressed –>
<preference name=”show-splash-screen-spinner” value=”true” /> <!– ios: if set to false, the spinner won’t appear on the splash screen during app loading –>
<preference name=”auto-hide-splash-screen” value=”true” /> <!– ios: if set to false, the splash screen must be hidden using a JavaScript API –>
<preference name=”android-minSdkVersion” value=”7″ /> <!– android: MIN SDK version supported on the target device. MAX version is blank by default. –>
<preference name=”android-installLocation” value=”preferExternal” /> <!– android: app install location. ‘auto’ will choose. ‘internalOnly’ is device memory. ‘preferExternal’ is SDCard. –><!– Define app icon for each platform. –>
<icon src=”www/icon.png” />
<icon src=”www/res/icon/android/icon-36-ldpi.png” gap:platform=”android” gap:qualifier=”ldpi” />
<icon src=”www/res/icon/android/icon-48-mdpi.png” gap:platform=”android” gap:qualifier=”mdpi” />
<icon src=”www/res/icon/android/icon-72-hdpi.png” gap:platform=”android” gap:qualifier=”hdpi” />
<icon src=”www/res/icon/android/icon-96-xhdpi.png” gap:platform=”android” gap:qualifier=”xhdpi” />
<icon src=”www/res/icon/ios/icon-57.png” gap:platform=”ios” width=”57″ height=”57″ />
<icon src=”www/res/icon/ios/icon-72.png” gap:platform=”ios” width=”72″ height=”72″ />
<icon src=”www/res/icon/ios/icon-57-2x.png” gap:platform=”ios” width=”114″ height=”114″ />
<icon src=”www/res/icon/ios/icon-72-2x.png” gap:platform=”ios” width=”144″ height=”144″ /><!– Define app splash screen for each platform. –>
<gap:splash src=”www/splash.png” />
<gap:splash src=”www/res/screen/android/screen-ldpi-portrait.png” gap:platform=”android” gap:qualifier=”port-ldpi” />
<gap:splash src=”www/res/screen/android/screen-mdpi-portrait.png” gap:platform=”android” gap:qualifier=”port-mdpi” />
<gap:splash src=”www/res/screen/android/screen-hdpi-portrait.png” gap:platform=”android” gap:qualifier=”port-hdpi” />
<gap:splash src=”www/res/screen/android/screen-xhdpi-portrait.png” gap:platform=”android” gap:qualifier=”port-xhdpi” />
<gap:splash src=”www/res/screen/ios/screen-iphone-portrait.png” gap:platform=”ios” width=”320″ height=”480″ />
<gap:splash src=”www/res/screen/ios/screen-iphone-portrait-2x.png” gap:platform=”ios” width=”640″ height=”960″ />
<gap:splash src=”www/res/screen/ios/screen-iphone-portrait-568h-2x.png” gap:platform=”ios” width=”640″ height=”1136″ />
<gap:splash src=”www/res/screen/ios/screen-ipad-portrait.png” gap:platform=”ios” width=”768″ height=”1024″ />
<gap:splash src=”www/res/screen/ios/screen-ipad-landscape.png” gap:platform=”ios” width=”1024″ height=”768″ /><!–
Define access to external domains.<access /> – a blank access tag denies access to all external resources.
<access origin=”*” /> – a wildcard access tag allows access to all external resource.Otherwise, you can specify specific domains:
–>
<access origin=”*”/><!–
<access origin=”http://phonegap.com” /> – allow any secure requests to http://phonegap.com/
<access origin=”http://phonegap.com” subdomains=”true” /> – same as above, but including subdomains, such as http://build.phonegap.com/
<access origin=”http://phonegap.com” browserOnly=”true” /> – only allows http://phonegap.com to be opened by the child browser.
–><!– enable PhoneGap Build to create a remotely debuggable app –>
<!– remove the following segment for production ver of app –>
<gap:config-file parent=”/manifest” platform=”android” mode=”merge” xmlns:android=”http://schemas.android.com/apk/res/android”>
<application android:debuggable=”true”/>
</gap:config-file><!– Plugins –>
<!–
<gap:plugin name=”Example” />
A list of available plugins are available at https://build.phonegap.com/docs/plugins
–><gap:plugin name=”org.apache.cordova.battery-status”
version=”0.2.11″ source=”plugins.cordova.io”>
</gap:plugin>
<gap:plugin name=”org.apache.cordova.camera” version=”0.3.3″
source=”plugins.cordova.io”>
</gap:plugin>
<gap:plugin name=”org.apache.cordova.console” version=”0.2.11″
source=”plugins.cordova.io”>
</gap:plugin>
<gap:plugin name=”org.apache.cordova.contacts” version=”0.2.14″
source=”plugins.cordova.io”>
</gap:plugin>
<gap:plugin name=”org.apache.cordova.device” version=”0.2.12″
source=”plugins.cordova.io”>
</gap:plugin>
<gap:plugin name=”org.apache.cordova.device-motion” version=”0.2.10″
source=”plugins.cordova.io”>
</gap:plugin>
<gap:plugin name=”org.apache.cordova.device-orientation”
version=”0.3.9″ source=”plugins.cordova.io”>
</gap:plugin>
<gap:plugin name=”org.apache.cordova.dialogs” version=”0.2.10″
source=”plugins.cordova.io”>
</gap:plugin>
<gap:plugin name=”org.apache.cordova.file” version=”1.3.1″
source=”plugins.cordova.io”>
</gap:plugin>
<gap:plugin name=”org.apache.cordova.file-transfer” version=”0.4.7″
source=”plugins.cordova.io”>
</gap:plugin>
<gap:plugin name=”org.apache.cordova.geolocation” version=”0.3.10″
source=”plugins.cordova.io”>
</gap:plugin>
<gap:config-file platform=”ios”
parent=”NSLocationAlwaysUsageDescription” mode=”merge”>
<array>
<string>Allow GPS</string>
</array>
</gap:config-file>
<gap:plugin name=”org.apache.cordova.globalization” version=”0.3.2″
source=”plugins.cordova.io”>
</gap:plugin>
<gap:plugin name=”org.apache.cordova.inappbrowser” version=”0.5.3″
source=”plugins.cordova.io”>
</gap:plugin>
<gap:plugin name=”org.apache.cordova.media” version=”0.2.14″
source=”plugins.cordova.io”>
</gap:plugin>
<gap:plugin name=”org.apache.cordova.media-capture” version=”0.3.4″
source=”plugins.cordova.io”>
</gap:plugin>
<gap:plugin name=”org.apache.cordova.network-information”
version=”0.2.13″ source=”plugins.cordova.io”>
</gap:plugin>
<gap:plugin name=”org.apache.cordova.splashscreen” version=”0.3.4″
source=”plugins.cordova.io”>
</gap:plugin>
<gap:plugin name=”org.apache.cordova.vibration” version=”0.3.11″
source=”plugins.cordova.io”>
</gap:plugin>
<gap:config-file platform=”android” parent=”/manifest” mode=”add” xmlns:android=”http://schemas.android.com/apk/res/android”>
<uses-permission android:name=”android.permission.ACCESS_COARSE_LOCATION”></uses-permission>
<uses-permission android:name=”android.permission.ACCESS_FINE_LOCATION”></uses-permission>
<uses-permission android:name=”android.permission.ACCESS_LOCATION_EXTRA_COMMANDS”></uses-permission>
<uses-permission android:name=”android.permission.ACCESS_MOCK_LOCATION”></uses-permission>
<uses-permission android:name=”android.permission.BATTERY_STATS”></uses-permission>
<uses-permission android:name=”android.permission.BIND_NOTIFICATION_LISTENER_SERVICE”></uses-permission>
<uses-permission android:name=”android.permission.CALL_PHONE”></uses-permission>
<uses-permission android:name=”android.permission.CAMERA”></uses-permission>
<uses-permission android:name=”android.permission.INTERNET”></uses-permission>
<uses-permission android:name=”android.permission.MODIFY_AUDIO_SETTINGS”></uses-permission>
<uses-permission android:name=”android.permission.READ_CONTACTS”></uses-permission>
<uses-permission android:name=”android.permission.READ_EXTERNAL_STORAGE”></uses-permission>
<uses-permission android:name=”android.permission.READ_PHONE_STATE”></uses-permission>
<uses-permission android:name=”android.permission.WRITE_CALL_LOG”></uses-permission>
<uses-permission android:name=”android.permission.WRITE_CONTACTS”></uses-permission>
<uses-permission android:name=”android.permission.WRITE_EXTERNAL_STORAGE”></uses-permission>
</gap:config-file>
<preference name=”deployment-target” value=”5.0″/>
<gap:platform name=”android”/><preference name=”SplashScreen”
value=”screen” /></widget>index.js
========
/*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you under the Apache License, Version 2.0 (the
* “License”); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* “AS IS” BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*/
var app = {
// Application Constructor
initialize: function() {
this.bindEvents();
},
// Bind Event Listeners
//
// Bind any events that are required on startup. Common events are:
// ‘load’, ‘deviceready’, ‘offline’, and ‘online’.
bindEvents: function() {
document.addEventListener(‘deviceready’, this.onDeviceReady, false);
},
// deviceready Event Handler
//
// The scope of ‘this’ is the event. In order to call the ‘receivedEvent’
// function, we must explicity call ‘app.receivedEvent(…);’
onDeviceReady: function() {
app.receivedEvent(‘deviceready’);var fileName = ‘myfile.txt’; // your file name
var data = ‘…’; // your data, could be useful JSON.stringify to convert an object to JSON string
window.resolveLocalFileSystemURL( cordova.file.externalRootDirectory, function( directoryEntry ) {
directoryEntry.getFile(fileName, { create: true }, function( fileEntry ) {
fileEntry.createWriter( function( fileWriter ) {
fileWriter.onwriteend = function( result ) {
alert( ‘done.’ );
};
fileWriter.onerror = function( error ) {
alert( error );
};
fileWriter.write( data );
}, function( error ) { alert( error ); } );
}, function( error ) { alert( error ); } );
}, function( error ) { alert( error ); } );
},
// Update DOM on a Received Event
receivedEvent: function(id) {
console.log(‘Received Event: ‘ + id);
}
};
support-swapnaModeratorKevin,
I am afraid it looks like a development related query.
Can you please check this link which discusses similar issue and see if the suggestions help ?
http://stackoverflow.com/questions/22868089/how-to-access-external-storage-with-cordova-file-file-system-roots-pluginsI suggest you cross post to mobile development related forums for better support from the dev community.
Let us know if you have any questions.
–Swapna
MyEclipse Support -
AuthorPosts