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?

27th Jan 2020, 1:03 AM
Y AD Ù
Y AD Ù - avatar
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())
27th Jan 2020, 6:35 AM
VEDANG
VEDANG - avatar
+ 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.
27th Jan 2020, 1:37 AM
Tony
Tony - avatar
27th Jan 2020, 2:11 AM
Tony
Tony - avatar
+ 7
python See if this applies for you.
27th Jan 2020, 6:00 AM
👑 Prometheus 🇸🇬
👑 Prometheus 🇸🇬 - avatar
+ 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?
27th Jan 2020, 2:47 AM
Tony
Tony - avatar
+ 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.
27th Jan 2020, 2:35 AM
Tony
Tony - avatar
+ 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..?
27th Jan 2020, 1:59 AM
Y AD Ù
Y AD Ù - avatar
+ 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
27th Jan 2020, 2:28 AM
Y AD Ù
Y AD Ù - avatar
+ 2
XXX i got it without enabling storage permissions
28th Jan 2020, 12:29 PM
Y AD Ù
Y AD Ù - avatar
+ 1
Ooh ohkay Anthony Quick 😁
27th Jan 2020, 3:32 AM
Y AD Ù
Y AD Ù - avatar
+ 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.
27th Jan 2020, 10:59 AM
XXX
XXX - avatar
+ 1
VEDANG it worked for me brother...!
27th Jan 2020, 4:04 PM
Y AD Ù
Y AD Ù - avatar
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..
27th Jan 2020, 2:42 AM
Y AD Ù
Y AD Ù - avatar
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)
16th May 2024, 12:28 AM
Patrick Ruff
Patrick Ruff - avatar