sterlingy Active Member Licensed User Longtime User Apr 9, 2013 #1 I've seen various posts on this, and I've tried different things to no avail. Code: Copy If File.ExternalWritable Then File.MakeDir(File.DirRootExternal, "Scooper") Dir = File.DirRootExternal & "/PooperScooper" Else File.MakeDir(File.DirRootExternal, "Scooper") Dir = File.DirRootExternal & "/Scooper" Log("dir: " & Dir) End If Here is where the directory was created, using DirRootExternal: "/storage/emulated/0/Scooper" I'm running this on a Nexus 7, which doesn't have external storage. So then I forced it to use DirInternal and this is where it put the directory: "/data/data/b4a.example/files/Scooper" Needless to say, I can't find either of the directories on my device. Any clues? -Sterling
I've seen various posts on this, and I've tried different things to no avail. Code: Copy If File.ExternalWritable Then File.MakeDir(File.DirRootExternal, "Scooper") Dir = File.DirRootExternal & "/PooperScooper" Else File.MakeDir(File.DirRootExternal, "Scooper") Dir = File.DirRootExternal & "/Scooper" Log("dir: " & Dir) End If Here is where the directory was created, using DirRootExternal: "/storage/emulated/0/Scooper" I'm running this on a Nexus 7, which doesn't have external storage. So then I forced it to use DirInternal and this is where it put the directory: "/data/data/b4a.example/files/Scooper" Needless to say, I can't find either of the directories on my device. Any clues? -Sterling
bgsoft Well-Known Member Licensed User Longtime User Apr 9, 2013 #2 Hi Sterling I'm not very expert in B4A, but I think you're confusing terms: File.DirRootExternal = / storage/sdcard0. No external memory card File.DirDefaultExternal = / storage/sdcard0/Android/data / "Package Name"/ files File.DirInternal = / data / data / "Package Name" / files The folder in the device internal storage that is uses to save application private data. If you want to know where each directory you can do something as simple as: Code: Copy Sub Activity_Click ' for test Log("File.ExternalWritable = " & File.ExternalWritable) Log("File.DirDefaultExternal= " & File.DirDefaultExternal) Log("File.DirRootExternal= " & File.DirRootExternal) Log("File.DirInternal= " & File.DirInternal) End Sub Hope that helps Jesus Upvote 0
Hi Sterling I'm not very expert in B4A, but I think you're confusing terms: File.DirRootExternal = / storage/sdcard0. No external memory card File.DirDefaultExternal = / storage/sdcard0/Android/data / "Package Name"/ files File.DirInternal = / data / data / "Package Name" / files The folder in the device internal storage that is uses to save application private data. If you want to know where each directory you can do something as simple as: Code: Copy Sub Activity_Click ' for test Log("File.ExternalWritable = " & File.ExternalWritable) Log("File.DirDefaultExternal= " & File.DirDefaultExternal) Log("File.DirRootExternal= " & File.DirRootExternal) Log("File.DirInternal= " & File.DirInternal) End Sub Hope that helps Jesus
I Inman Well-Known Member Licensed User Longtime User Apr 9, 2013 #3 sterlingy said: I'm running this on a Nexus 7, which doesn't have external storage. Click to expand... On devices like Nexus 7 which doesn't have an sd card slot (and on devices like Galaxy S3 which has a large internal memory, in addition to the card slot), a large portion of the internal memory gets mounted as virtual SD card. And that is where the directory will get created when you use RootExternal or DefaultExternal. Upvote 0
sterlingy said: I'm running this on a Nexus 7, which doesn't have external storage. Click to expand... On devices like Nexus 7 which doesn't have an sd card slot (and on devices like Galaxy S3 which has a large internal memory, in addition to the card slot), a large portion of the internal memory gets mounted as virtual SD card. And that is where the directory will get created when you use RootExternal or DefaultExternal.
sterlingy Active Member Licensed User Longtime User Apr 9, 2013 #4 This is what truly puzzles me: Later in my code, I write to a file: Code: Copy Dim raf As RandomAccessFile raf.Initialize(File.DirRootExternal, "optionSetting.txt", False) raf.WriteObject(opMusicCtrl.Top, True,raf.CurrentPosition) raf.WriteObject(opSFXCtrl.Top, True,raf.CurrentPosition) raf.Close If the file doesn't exist, it is created, and this is in the DirRootExternal. So why won't it make the directory in the same folder? -Sterling Upvote 0
This is what truly puzzles me: Later in my code, I write to a file: Code: Copy Dim raf As RandomAccessFile raf.Initialize(File.DirRootExternal, "optionSetting.txt", False) raf.WriteObject(opMusicCtrl.Top, True,raf.CurrentPosition) raf.WriteObject(opSFXCtrl.Top, True,raf.CurrentPosition) raf.Close If the file doesn't exist, it is created, and this is in the DirRootExternal. So why won't it make the directory in the same folder? -Sterling
sterlingy Active Member Licensed User Longtime User Apr 9, 2013 #5 When I run the app on my GalaxyS 3, it creates the file and the directory, in the same internal root directory that the file was created on the nexus, despite the fact that the GS3 does have an external memory card. -Sterling Upvote 0
When I run the app on my GalaxyS 3, it creates the file and the directory, in the same internal root directory that the file was created on the nexus, despite the fact that the GS3 does have an external memory card. -Sterling
bgsoft Well-Known Member Licensed User Longtime User Apr 9, 2013 #6 Hello I do not understand your problem. I tried your code and creates the file in File.DirRootExternal, which is: storage/sdcard0 Where do you want to create the file? if you want to save on the external memory card, you'll have to put this: /storage/extSdCard Uses a filemanager app and you will know what your name is. Or you can use the FileDialog of b4a Jesus Upvote 0
Hello I do not understand your problem. I tried your code and creates the file in File.DirRootExternal, which is: storage/sdcard0 Where do you want to create the file? if you want to save on the external memory card, you'll have to put this: /storage/extSdCard Uses a filemanager app and you will know what your name is. Or you can use the FileDialog of b4a Jesus
sterlingy Active Member Licensed User Longtime User Apr 9, 2013 #7 I don't really care where the directory is created. My point is that it seems to work on my GS3 but not my Nexus7. Both can create a file in DirRootExternal, but only the GS3 can make a directory in DirRootExternal. -Sterling Upvote 0
I don't really care where the directory is created. My point is that it seems to work on my GS3 but not my Nexus7. Both can create a file in DirRootExternal, but only the GS3 can make a directory in DirRootExternal. -Sterling
bgsoft Well-Known Member Licensed User Longtime User Apr 9, 2013 #8 Try adding this in the Manifest, but it should work, but sometimes not known. AddPermission (android.permission.READ_EXTERNAL_STORAGE) ------------- public static final String READ_EXTERNAL_STORAGE Added in API level 16 Allows an application to read from external storage. Any app that declares the WRITE_EXTERNAL_STORAGE permission is implicitly granted this permission. Currently, this permission is not enforced and all apps still have access to read from external storage without this permission. That will change in a future release and apps will require this permission to read from external storage. So if your app reads from the external storage, you should add this permission to your app now to ensure that it continues to work on future versions of Android. You can test your app with the permission enforced by either running your app on the Android Emulator when running Android 4.1 or higher, or enabling Protect USB storage under Developer options in the Settings app on a device running Android 4.1 or higher. Note: If both your minSdkVersion and targetSdkVersion values are set to 3 or lower, the system implicitly grants your app this permission. If you don't need this permission, be sure your targetSdkVersion is 4 or higher. Constant Value: "android.permission.READ_EXTERNAL_STORAGE" --------------- Jesus Upvote 0
Try adding this in the Manifest, but it should work, but sometimes not known. AddPermission (android.permission.READ_EXTERNAL_STORAGE) ------------- public static final String READ_EXTERNAL_STORAGE Added in API level 16 Allows an application to read from external storage. Any app that declares the WRITE_EXTERNAL_STORAGE permission is implicitly granted this permission. Currently, this permission is not enforced and all apps still have access to read from external storage without this permission. That will change in a future release and apps will require this permission to read from external storage. So if your app reads from the external storage, you should add this permission to your app now to ensure that it continues to work on future versions of Android. You can test your app with the permission enforced by either running your app on the Android Emulator when running Android 4.1 or higher, or enabling Protect USB storage under Developer options in the Settings app on a device running Android 4.1 or higher. Note: If both your minSdkVersion and targetSdkVersion values are set to 3 or lower, the system implicitly grants your app this permission. If you don't need this permission, be sure your targetSdkVersion is 4 or higher. Constant Value: "android.permission.READ_EXTERNAL_STORAGE" --------------- Jesus
sterlingy Active Member Licensed User Longtime User Apr 9, 2013 #9 Things are working. I didn't have to change the manifest. The error was in the communication between my PC and the device. I was using windows to browse the device, and even search for the specific folder and files, but it never returned any results. Eventually, I opened up ES File Explorer on the device, and sure enough, everything was there. I guess I won't be using the PC to look for files on the device anymore. Cheers, Sterling Upvote 0
Things are working. I didn't have to change the manifest. The error was in the communication between my PC and the device. I was using windows to browse the device, and even search for the specific folder and files, but it never returned any results. Eventually, I opened up ES File Explorer on the device, and sure enough, everything was there. I guess I won't be using the PC to look for files on the device anymore. Cheers, Sterling
bgsoft Well-Known Member Licensed User Longtime User Apr 10, 2013 #10 I'm glad it works for you. That happened to me once and I saw the problem with the phone filemanager. After changing something on the phone, if you leave and re-enter Windows Explorer PC will have the information OK regards Jesus Upvote 0
I'm glad it works for you. That happened to me once and I saw the problem with the phone filemanager. After changing something on the phone, if you leave and re-enter Windows Explorer PC will have the information OK regards Jesus