0
How to solve PermissionError in Pydroid
file =open("/storage/emulated/0/txtpad/Text.txt") print(file.read()) I created Text.txt file via a notepad app which has the above memory location..but when i try to open it in Android via Pydroid i get a PermissionError..how to solve this?
14 Respuestas
+ 6
I used this code and opened "toRead.txt" in pydroid and it works:
file = open("toRead.txt")
print (file. read ())
I saved both the txt file and py file in same directory.
You can use this code to see the current working directory:
import os
print (os.getcwdb())
+ 7
I'm not a Pydroid user unfortunately, so I have very little idea on the matter, but from experience with other apps I would check a couple things:
1. Are permissions properly enabled?
2. Is the file in a location that Pydroid is allowed to access?
Try moving your file to the location Pydroid uses for saving it's files, and see if that works. Usually files belonging to other apps will not be able to be opened via non-parent apps, which I think is probably the issue here. Worst case scenario, just make a new file directly with Pydroid, and only use that instead of the notepad app. Cheers, and I hope that helps at least a little.
+ 7
Y AD Ù have a look at this mate: https://www.sololearn.com/post/229093/?ref=app
+ 7
python
See if this applies for you.
+ 5
Ahhh I see. I assume you need to link a database to store user inputs. I'm not familiar with Pydroid at all though, so not sure how to do that. Maybe somebody will come along that can help. 🌟(Pro)metheus 🇸🇬 any ideas mate?
+ 3
Once you open a new file, you can start typing directly in the screen that opens up. Then make sure and save your file.
+ 2
Anthony Quick Pydroid asks us on where to save the file..so i gave it the place where the notepad app saves its file..but still aint working..
And can i knw how to make a new file directly..?
+ 2
Great Anthony Quick but how can I modify that "New" File via a code..like how can i write to that file
https://www.sololearn.com/post/229104/?ref=app
+ 2
XXX i got it without enabling storage permissions
+ 1
Ooh ohkay Anthony Quick 😁
+ 1
Y AD Ù I just tried it out. The problem is you have not enabled Storage permissions for Pydroid. Go to your phone settings, and go wherever there is an option for app permissions. Click on Pydroid and enable the storage permissions.
+ 1
VEDANG it worked for me brother...!
0
Anthony Quick mate ..my aim was to receive certain inputs from the user and save it to a file to output it at a later stage in the code..
0
I use Android, it's in Settings/Privacy/Storage/ then you click see more Apps, then find Pydroid or whatever app and you then toggle on the permission to access files on your phone (it's off by default)