SDCArd write problem

Koverhage

Member
Licensed User
Longtime User
Hi,

i use a Samsung Galaxy Tablet with Android 3.2. This version has a bug,
so the external sd card is readonly.

With File.DirRootExternal i have the path to the readonly sd card.
The solution should be
Before Honeycomb 3.2, apps only had to request for the permission WRITE_EXTERNAL_STORAGE and they would have write access to both the internal and external so-called "sdcard" sets of memory. Now, apps have to request for WRITE_MEDIA_STORAGE if they want to write to the external SD card, but many of them have not yet been updated to do so yet. This affects file managers / explorer / compression utility type apps most often because users would tend to use them to copy / move / zip files within the file system.

Link to the Thread: SDCard write problem fix for Samsung Galaxy Tab 7.7 GT-P6800 ~ AfterNote

But how i can do this in B4A ?

Klaus
 
Hi Erel,

i added this to the manifest file, but without success.

I have found this additional information
<permission name="android.permission.WRITE_EXTERNAL_STORAGE" >
<group gid="sdcard_rw" />
<group gid="media_rw" />
</permission>

(Google – xda-developers)

I added this also to the manifest file

AddPermission(android.permission.WRITE_MEDIA_STORAGE)
AddManifestText(<permission name="android.permission.WRITE_EXTERNAL_STORAGE" >
<group gid="sdcard_rw" />
<group gid="media_rw" />
</permission>)

but also without success.
 
Upvote 0
Hi,

I am not shure, but I think that the manifest file is written by the IDE, while compiling and inside the installation package.

It should be possible to add this line inside the IDE, but I don't know where ?
If got the same problem :sign0085:
 
Upvote 0
would this be the right way to add behind the default text ?
Code: Copy
'This code will be applied to the manifest file during compilation.
'You do not need to modify it in most cases.
'See this link for for more information: http://www.b4x.com/forum/showthread.php?p=78136
AddManifestText(
<uses-sdk android:minSdkVersion="4" />
<supports-screens android:largeScreens="true" 
    android:normalScreens="true" 
    android:smallScreens="true" 
    android:anyDensity="true"/>)
SetApplicationAttribute(android:icon, "@drawable/icon")
SetApplicationAttribute(android:label, "$LABEL$")
'End of default text.
' Test for Samsung Tablet with write error on SDCARD
AddPermission(android.permission.WRITE_MEDIA_STORAGE)
 
Upvote 0
I do it this way

'This code will be applied to the manifest file during compilation.
'You do not need to modify it in most cases.
'See this link for for more information: Manifest Editor
AddManifestText(
<uses-sdk android:minSdkVersion="4" />
<supports-screens android:largeScreens="true"
android:normalScreens="true"
android:smallScreens="true"
android:anyDensity="true"/>)
SetApplicationAttribute(android:icon, "@drawable/icon")
SetApplicationAttribute(android:label, "$LABEL$")
AddPermission(android.permission.WRITE_MEDIA_STORAGE)
AddManifestText(<permission name="android.permission.WRITE_EXTERNAL_STORAGE" >
<group gid="sdcard_rw" />
<group gid="media_rw" />
</permission>)

'End of default text.

The result is, i can't install the apk -> error parsing the package.
 
Upvote 0
Hubert,

i add this in the default section. If i look at the AndroidManifest.xml
the AddPermission command is at the right place.

But here the
AddManifestText(<permission name="android.permission.WRITE_EXTERNAL_STORAGE" >
<group gid="sdcard_rw" />
<group gid="media_rw" />
</permission>)
is inserted before the AddPermission command. I think this must behind the
AddPermission and i don't know if the syntax is correct.
 
Upvote 0
Hubert,

i add this in the default section. If i look at the AndroidManifest.xml
the AddPermission command is at the right place.

But here the
AddManifestText(<permission name="android.permission.WRITE_EXTERNAL_STORAGE" >
<group gid="sdcard_rw" />
<group gid="media_rw" />
</permission>)
is inserted before the AddPermission command. I think this must behind the
AddPermission and i don't know if the syntax is correct.

If I do so, the manifest is not accepted (malformed or so).
 
Upvote 0
Code: Copy
'This code will be applied to the manifest file during compilation.
'You do not need to modify it in most cases.
'See this link for for more information: http://www.b4x.com/forum/showthread.php?p=78136
AddManifestText(
<uses-sdk android:minSdkVersion="4" />
<supports-screens android:largeScreens="true" 
    android:normalScreens="true" 
    android:smallScreens="true" 
    android:anyDensity="true"/>)
SetApplicationAttribute(android:icon, "@drawable/icon")
SetApplicationAttribute(android:label, "$LABEL$")
'End of default text.
' Test for Samsung Tablet with write error on SDCARD
AddPermission(android.permission.WRITE_MEDIA_STORAGE) 
AddPermission(android.permission.WRITE_EXTERNAL_STORAGE)

I tried all variants, this was my last one, but it is still not writeable.
The function File.ExternalWritable results true. This looks than like the INTERNAL external SD card.
Any idea left ? :sign0085:

PS: I can't tell the users "root your device" ;-)
 
Upvote 0
I know nothing about the solution, but why not trying to insert files in dir.internal?
 
Upvote 0
Hi Erel,

i found this

<!-- Allows an application to write to internal media storage @hide -->
<permission android:name="android.permission.WRITE_MEDIA_STORAGE"
android:permissionGroup="android.permission-group.STORAGE"
android:label="@string/permlab_mediaStorageWrite"
android:description="@string/permdesc_mediaStorageWrite"
android:protectionLevel="signatureOrSystem" />

chainfire[dev~blog] - Is Google blocking apps writing to SD cards ?

but how i can add this to manifest.xml ?
 
Upvote 0
Project - Manifest editor:
Code: Copy
AddManifestText(<!-- Allows an application to write to internal media storage @hide -->
<permission android:name="android.permission.WRITE_MEDIA_STORAGE"
androidermissionGroup="android.permission-group.STORAGE"
android:label="@string/permlab_mediaStorageWrite"
android:description="@string/permdesc_mediaStorageWrite"
androidrotectionLevel="signatureOrSystem" />
)
 
Upvote 0
I got an compiler message:
Code: Copy
Packaging files.                        Error
AndroidManifest.xml:15: error: Error: No resource found that matches the given name (at 'label' with value '@string/permlab_mediaStorageWrite').
AndroidManifest.xml:15: error: Error: No resource found that matches the given name (at 'description' with value '@string/permdesc_mediaStorageWrite').
here is my input:
Code: Copy
'This code will be applied to the manifest file during compilation.
'You do not need to modify it in most cases.
'See this link for for more information: http://www.b4x.com/forum/showthread.php?p=78136
AddManifestText(
<uses-sdk android:minSdkVersion="4" />
<supports-screens android:largeScreens="true" 
    android:normalScreens="true" 
    android:smallScreens="true" 
    android:anyDensity="true"/>)
SetApplicationAttribute(android:icon, "@drawable/icon")
SetApplicationAttribute(android:label, "$LABEL$")
'End of default text.
' Test for Samsung Tablet with write error on SDCARD
'AddPermission(android.permission.WRITE_MEDIA_STORAGE) 
'AddPermission(android.permission.WRITE_EXTERNAL_STORAGE) 
AddManifestText(<!-- Allows an application to write to internal media storage @hide -->
<permission android:name="android.permission.WRITE_MEDIA_STORAGE"
androidermissionGroup="android.permission-group.STORAGE"
android:label="@string/permlab_mediaStorageWrite"
android:description="@string/permdesc_mediaStorageWrite"
androidrotectionLevel="signatureOrSystem" />
)
 
Upvote 0
Code: Copy
Compiling code.                         0.88
Compiling layouts code.                 0.05
Generating R file.                      0.00
Compiling generated Java code.          2.42
Convert byte code - optimized dex.      1.97
Packaging files.                        Error
AndroidManifest.xml:15: error: Error: No resource found that matches the given name (at 'label' with value '@string/permlab_mediaStorageWrite').
AndroidManifest.xml:15: error: Error: No resource found that matches the given name (at 'description' with value '@string/permdesc_mediaStorageWrite').

with this entry:
Code: Copy
'This code will be applied to the manifest file during compilation.
'You do not need to modify it in most cases.
'See this link for for more information: http://www.b4x.com/forum/showthread.php?p=78136
AddManifestText(
<uses-sdk android:minSdkVersion="4" />
<supports-screens android:largeScreens="true" 
    android:normalScreens="true" 
    android:smallScreens="true" 
    android:anyDensity="true"/>)
SetApplicationAttribute(android:icon, "@drawable/icon")
SetApplicationAttribute(android:label, "$LABEL$")
'End of default text.
' Test for Samsung Tablet with write error on SDCARD
'AddPermission(android.permission.WRITE_MEDIA_STORAGE) 
'AddPermission(android.permission.WRITE_EXTERNAL_STORAGE) 
AddManifestText(<!-- Allows an application to write to internal media storage @hide -->
<permission android:name="android.permission.WRITE_MEDIA_STORAGE"
android:permissionGroup="android.permission-group.STORAGE"
android:label="@string/permlab_mediaStorageWrite"
android:description="@string/permdesc_mediaStorageWrite"
androidrotectionLevel="signatureOrSystem" />
)
 
Upvote 0
Back
Top