Python Forum
KivyMD android app - problem with permission
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
KivyMD android app - problem with permission
#1
I created a simple app for viewing my weekly meal plan. It reads the SQLite database. The app worked on my old smartphone; however, it does not work on my new Pixel 7 smartphone. The issue is that my app does not have access to the smartphone's storage, where the database is localized. It was possible to grant that access with my old smartphone; however, it is not possible with the new one. So, I have to modify my app to make it request such permission. Unfortunately, I don't know how to do that. I tried with ChatGPT, but it didn't work.

Here is my simple code, which worked on my old smartphone:
from kivy.properties import StringProperty from kivy.lang import Builder from kivy.uix.tabbedpanel import TabbedPanel from kivymd.app import MDApp import functions meals = functions.getMealList() meal_list_for_kv_file = functions.getMealsFor_kv_File(meals) current_meal_name = '' kv_string = ''' <MyLayout>	do_default_tab: False	size_hint: 1, 1	# ft_top, left_mid, left_bottom, top_left,	# top_mid, top_right, right_top, right_mid,	# right_bottom, bottom_left, bottom_mid,	# bottom_right.	tab_pos: 'top_mid'	TabbedPanelItem:	text: "Meal List"	ScrollView:	MDList: {0}	TabbedPanelItem:	text: "Meal"	on_release: root.pressedMealTab()	BoxLayout:	orientation: 'vertical'	Label:	font_size: self.width/30 text_size: self.size halign: 'left' valign: 'top'	id: Label1Tab2_id	text: root.meal_ingredients	Label:	font_size: self.width/40 text_size: self.size halign: 'left' valign: 'top'	id: Label2Tab2_id	text: root.meal_recipe	TabbedPanelItem:	text: "Week"	on_release: root.pressedWeekTab()	BoxLayout:	orientation: 'vertical'	Label: text_size: self.size halign: 'left' valign: 'middle'	id: Label1Tab3_id	text: root.monday_meals	Label: text_size: self.size halign: 'left' valign: 'middle'	id: Label2Tab3_id	text: root.thuesday_meals	Label: text_size: self.size halign: 'left' valign: 'middle'	id: Label3Tab3_id	text: root.wednesday_meals	Label: text_size: self.size halign: 'left' valign: 'middle'	id: Label4Tab3_id	text: root.thursday_meals	Label: text_size: self.size halign: 'left' valign: 'middle'	id: Label5Tab3_id	text: root.friday_meals	Label: text_size: self.size halign: 'left' valign: 'middle'	id: Label6Tab3_id	text: root.saturday_meals	Label: text_size: self.size halign: 'left' valign: 'middle'	id: Label7Tab3_id	text: root.sunday_meals '''.format(meal_list_for_kv_file) # print(kv_string) # Designate Our .kv design file Builder.load_string(kv_string) class MyLayout(TabbedPanel):	meal_ingredients = StringProperty()	meal_recipe = StringProperty()	monday_meals = StringProperty()	thuesday_meals = StringProperty()	wednesday_meals = StringProperty()	thursday_meals = StringProperty()	friday_meals = StringProperty()	saturday_meals = StringProperty()	sunday_meals = StringProperty()	def pressedMealTab(self):	global current_meal_name	try:	self.ids.Label1Tab2_id.text = functions.getMealIngredientString(current_meal_name)	self.ids.Label2Tab2_id.text = functions.getMealRecipe(current_meal_name)	except:	print("YOU HAVEN'T CHOOSE A MEAL")	def pressedWeekTab(self):	try:	self.ids.Label1Tab3_id.text = functions.getMealsForASingleDay("MONDAY", "weekly_menu1_1")	self.ids.Label2Tab3_id.text = functions.getMealsForASingleDay("THUESDAY", "weekly_menu1_2")	self.ids.Label3Tab3_id.text = functions.getMealsForASingleDay("WEDNESDAY", "weekly_menu1_3")	self.ids.Label4Tab3_id.text = functions.getMealsForASingleDay("THURSDAY", "weekly_menu1_4")	self.ids.Label5Tab3_id.text = functions.getMealsForASingleDay("FRIDAY", "weekly_menu1_5")	self.ids.Label6Tab3_id.text = functions.getMealsForASingleDay("SATURDAY", "weekly_menu1_6")	self.ids.Label7Tab3_id.text = functions.getMealsForASingleDay("SUNDAY", "weekly_menu1_7")	except:	print("CAN'T GET WEEKLY MENU") class MealPlannerAndroid(MDApp):	def build(self):	return MyLayout()	def pressedMealOnList(self, pressed, list_id):	pressed.tertiary_text = f"You Pressed {list_id}"	#print(pressed.tertiary_text)	global current_meal_name	current_meal_name = list_id if __name__ == '__main__':	MealPlannerAndroid().run()
And here is the modified by chatGPT code, which does not work:
https://pastebin.com/Rfd79a32

And here is the functions.py file:
https://pastebin.com/TkG82VhY

How to solve this problem?
Reply


Possibly Related Threads…
Thread Author Replies Views Last Post
  Potential Permission error on Mac OSX Catalina OWOLLC 2 3,491 Apr-24-2025, 04:45 AM
Last Post: TomBrooks
  The INSERT permission was denied on the object Steven5055 3 3,811 Jun-12-2024, 08:13 AM
Last Post: GregoryConley
  Delete file with read-only permission, but write permission to parent folder cubei 6 28,793 Jun-01-2024, 07:22 AM
Last Post: Eleanorreo
  logging: change log file permission with RotatingFileHandler erg 0 3,536 Aug-09-2023, 01:24 PM
Last Post: erg
  KivyMD App to APK Convert Error Nick_MC 0 4,614 Jul-18-2022, 08:59 AM
Last Post: Nick_MC
  Permission issue when using scapy jao 3 21,595 Feb-05-2022, 06:14 PM
Last Post: snippsat
  Error no 13: Permission denied in python shantanu97 1 11,076 Mar-31-2021, 02:15 PM
Last Post: snippsat
  How a Mac OS software can restart itself with admin permission in Python 3.7? Formationgrowthhacking 0 2,807 Sep-03-2020, 05:29 PM
Last Post: Formationgrowthhacking
  Error 13 permission tpolim008 2 5,565 Apr-09-2020, 06:22 PM
Last Post: tpolim008
  Fixing "PermissionError: [Errno 13] Permission denied" puredata 17 103,374 Mar-09-2020, 03:20 PM
Last Post: syssy

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020
This forum uses Lukasz Tkacz MyBB addons.
Forum use Krzysztof "Supryk" Supryczynski addons.