Problems with storage, reading and writing files after Android 10

文章推薦指數: 80 %
投票人數:10人

I have created an app that allows me to collect data, which is stored in a CSV file. Prior to the release of Android 10, this CSV file was stored on the ... Problemswithstorage,readingandwritingfilesafterAndroid10 MITAppInventorHelp android10 Luke_Duncan October1,2020,9:42pm #1 Ihavecreatedanappthatallowsmetocollectdata,whichisstoredinaCSVfile.PriortothereleaseofAndroid10,thisCSVfilewasstoredontheeternalstorage(/APPNAME/data/filename.csv).Theappalsoexportedthefiletoanotherlocationfromwhichitcouldbedownloadedontomycomputer.AsIunderstandthings,Googlehavenowrestrictedthewaysinwhichappsareabletoread/writetostorageoutsideoftheapp'sspecificstoragedirectoryand,assuch,myappisnolongerabletoreadorwritetothefilesthatitusedto. Ihavereadonthereleasenotesfornb185andnb185a,therecommendationistomigrateallfiles-basedstoragetotheapp-specificstorage.Howshouldonedothis?IwasreadinguponthisandspecificallyreadAnke'spostherebutwhenItriedtousetheapp-specificdirectorypathsheprovided,itdidnotwork.HowdoIworkaroundthis? Filedoesnotexist Salman_Dev September30,2020,2:51pm #2 Lookatthis: Can'tcreatefolderinAndroid10BugsandOtherIssues Youcoulduseanextensionorcodelikeshownhere: [androidVersion]whichusesanhtmlfileinMediaasshown. Fora2.2emulator,thiscodereturns2;foranAndroidtablet8.1.0itreturns8. Theexampleworksandtestedonan2.2thruAndroid8;resultsmightbedifferentonAndroid9+AndroidVersion.aia(3.7KB) Howtolist(specific)filesfromtheassetsonAndroid≥10(API≥29)→CompanionTutorialsandGuides Thiswayyoucanlist(specific)filesfromassetsusingCompanion,ifyourdeviceisrunningAndroid10orhigher: [grafik] →https://puravidaapps.com/file.php →https://puravidaapps.com/tools.php TIMAI2 September30,2020,3:02pm #3 AlsoreadthisfromEvan: FilePathUpdatesStartingwithAndroid10(Evan'sBlog) 1Like patel September30,2020,6:26pm #4 HavealooktoCannotwritetextfile Luke_Duncan November18,2020,7:29am #5 Thankyoufortheresponseshere.However,havinglookedthroughthesuggestionsprovidedIamnonethewiserastohowtogoaboutexportingmyfilestoadirectorythatisnottheapp'sprivatedirectory.TheproblemthatIhaveisthatIneedtobeabletoexportthefilestobedownloadedoffthedevice(specificallyNOTusinganinternet/cloud-basedexportsystem-theappisspecificallyforuseinaremoteareawithnointernetaccess)andsosimplywriting/exportingtotheapp'sprivatedirectorydoesnothelpme.IapologiseifIambeingobtuseherebutIneedsomeonetoliterallyspelloutformehowtodothis. InadditiontothisIhaveanotherquestionthathasemergedthroughtryingtosolvethisproblem:myunderstandingisthatifIexcludetheslashfromafilereference(i.e.'file.csv'insteadof'/file.csv')theappwillutilisetheapp-specificprivatedirectoryforthatreference.Ifthatisthecase,howcanIbesurethatthefileisactuallybeingwrittento?Icannotaccesstheapp-specificdirectoryonthedeviceandsothereisnowayformetocheckifthefileisbeingmodifiedwithouthavingtheapptodisplayalistorsomethingsimilarwiththecontentsofthefileaftereverytimetheappissupposedtowritetothefile. patel November18,2020,8:12am #6 ThisismyblocktoreadacsvonAndroid10,IcheckedLegacymodeonfile1component blocks(3)848×18013.8KB Idon'tknowifitrunsonAndroid11 Anke November18,2020,12:30pm #7 patel: Idon'tknowifitrunsonAndroid11 ItwillworkonAndroid10and11untilAI2targetsAPI30. Taifun November18,2020,9:33pm #8 Luke_Duncan: simplywriting/exportingtotheapp'sprivatedirectorydoesnothelpme ifyoustorethefilesintheapplicationspecificdirectory,yourappstillwillworkafterAppInventortargetsAPI30inlate2021 Luke_Duncan: ifIexcludetheslashfromafilereference(i.e.'file.csv'insteadof'/file.csv')theappwillutilisetheapp-specificprivatedirectoryforthatreference. no,thisistheprivatedirectory...theapplicationspecificdirectoryisdifferent... seealso SomebasicsonAndroidstoragesystem FromanAndroidpointofviewtherearean→InternalStorageandan→ExternalStorage.1.InternalStorageTheInternalStoragecanonlybeaccessedwitharooteddevice.1.1Theapppackageissavedin/data/data//1.2.ThePrivatedirectory... Readingtime:1mins🕑 Likes:28❤ Luke_Duncan: Icannotaccesstheapp-specificdirectoryonthedevice youcan,youonlyhavetousethecorrectpathoranextension,forexamplethefileextension(therearealsootherextensions) Taifun Tryingtopushthelimits!Snippets,TutorialsandExtensionsfromPuraVidaAppsbyTaifun. 1Like Errorwhenopeningpdf VideoPlayer-source ejb March12,2021,6:43pm #9 Thanksforalltheseinfo,ithelps..butIneedalittlebitmore HISTORY:TheReadFilepartofmy"old"appdidnotworkanymoreonmynewphone(Android10).Patel'sinputaboutcheckingthe"Legacymode"reallyhelped,thanksButmyissuenowistounderstandhowtoupdatemyappforfutureAndroidreleases. REQUIREMENT:Ionlyneedto"READ"filesmanuallystoredonmycell.TheyallaregeneratedoutofExcelmacrosonmyPC.Iupdate/regeneratetheyfromtimetotimeonmyPC,beforecopyingthemovermycellusinga"simple"USBcable UNDERSTANDING:BearinginmindIjustwouldliketokeepperforminginthefuturea"callFile1.ReadFrom"asdepictedbyPatel,andrememberingIneedtocopymyfilesfromaPCtomycell,itsoundslikeIwillneedtouseafilepathonthecellthatleadstotheapp'sspecificdirectory.ReadingKodular's"SomebasicsonAndroidstoragesystem",Ialsounderstandthisisconsideredas"Externalstorage",entailingcertainpermissionsmanagement.Ialsounderstandtheexternalprivatestorage"/storage/emulated/0/Android/data//files/"doesn'tneedtheREADpermissiongranting,good QUESTION:Isthatno-READ-permission-external-private-storageaccessiblefrommyPCusingaUSBcabletocopymyfilestoit?Then,howcanItestallthisusingAI2companionwhennoappgotgeneratedyet?Easy..? Enjoy Eric Anke March13,2021,8:57am #10 ejb: Isthatno-READ-permission-external-private-storageaccessiblefrommyPCusingaUSBcabletocopymyfilestoit? Yes,buthowaboutjusttryingitoutinsteadofaskingquestionsthatareeasytoansweryourself. ejb: Then,howcanItestallthisusingAI2companionwhennoappgotgeneratedyet? Howshouldanapporcertainfunctionsofanappbetestedwithoutanapporanycodeexisting? Patryk_F March13,2021,9:26am #11 ejb: Then,howcanItestallthisusingAI2companionwhennoappgotgeneratedyet?Easy..? Companionisafuntool.Youcanquicklytestthelogicoftheprogram.However,intheend,it'sbesttotesteverythingonaphysicalphone.Evenforthesakeofappearance,becausetheappearanceoftheappinthecompaniondiffersfromthatwheninstalled. Itisapitythattheinventorappdoesnothaveastylelikecompanion,Iliketheonefromcompanionverymuch. ejb March14,2021,6:12pm #12 Anke: Yes,buthowaboutjusttryingitoutinsteadofaskingquestionsthatareeasytoansweryourself. Thanksforyourpromptreaction.ButIseethatnottellingyouthewholestorymadeituncleartoyou,sorryforthis. Asamatteroffact,Ididperformsometesting,whichconsistedof: TryingtoidentifyAICompanion'sexternalprivatestorageonmycellusing"MyFiles"app.Itlookedtobe: image694×14312.1KB Copyingoneofmyownfilesfrommyowndirectoryonthecelltotheoneabove(file"Al_DVD-list-1col.prn"asvisibleabove). ThentestingasusualmyAppwithCompaniononmycell..andthisworked ConnectingmycelltomyPCwithanUSBcableandopeningthecell'sdirectoryfrommyPC(W10)usingtheusualWindowsExplorer..andthenIgotthefollowing image767×35068.7KB So,fromthePC,myissuewasthatIhadnovisibilityonmyfile"Al_DVD-list-1col.prn",hencemy1stquestionaboutbeingornotabletoaccessano-READ-permission-external-private-storagefromaPC. ThenIuncheckedthe"Legacymode"flag..andmyappstoppedfunctioningagain So,eitherthat"edu.mit.appinventor.aicompanion3/files"isnotAICompanion'sexternalprivatestorage,eitheritistherightstorage,butsomethingelseblocksinAndroid.Eitherway,Idon'tgaintheknowledgejustreadingMITAI'sandothers'documentation..henceallmyquestions Anyclue? NOTE:Aboutyourothernote"Howshouldanapporcertainfunctionsofanappbetestedwithoutanapporanycodeexisting?"->ThisisnotwhatI'vetriedtoexpress. MyunderstandingofAICompanion,wrongperhaps,isthatitdoesn'tcompileontheflybutinterpretsAI'sblocks(orsomethingclosetothis),alittleliketheBASIClanguagea"long"timeagoSo,mynewappnotbeingyetcompiled(or"generated"inmyprevioussentence),thereshouldbenospecificapprelatedexternalprivatestorageyetexisting,hencemyquestion"howcanItestallthisusingAI2companionwhennoappgotgeneratedyet?" ..andforthis2ndquestion,I'mnowguessingI'llhavetodoallthisintwosteps,onetestwiththeappgenerated/downloadedontomycell,butnotfunctioningbecauseusingthewrongfiledirectoriespath,buthopefullyhavingthenvisibilityontheapp'snewlycreatedexternalprivatestorage,anda2ndtestafterhavingre-generatedtheappwiththecorrectfilepath..we'llsee Anke March15,2021,6:02am #13 ejb: ConnectingmycelltomyPCwithanUSBcableandopeningthecell'sdirectoryfrommyPC(W10)usingtheusualWindowsExplorer..andthenIgotthefollowing Ihavenoproblemswithitonmytestdevices(Android<10). Open/doubleclickthefolder/data/tolookifitisreallyempty. Iftrue,trytocopythefilefromyourPCtothatfolder. WhatversionofAndroidisyourdevice? Anke March15,2021,7:32am #14 ejb: TryingtoidentifyAICompanion'sexternalprivatestorageonmycellusing"MyFiles"app.Itlookedtobe: IhavenoaccesstotheASDonadevicewithAndroid≥10. grafik468×57821.4KB ejb March15,2021,10:52am #15 Anke: Ihavenoproblemswithitonmytestdevices(Android<10). Open/doubleclickthefolder/data/tolookifitisreallyempty. Iftrue,trytocopythefilefromyourPCtothatfolder. WhatversionofAndroidisyourdevice? Fromthescreenshotitself,onecanseeIhadalreadyopenedthe"data"folder(->screenshotlefthandside:folder"data"ishighlightedingrey,andalso->screenshottopside:thepathreadsfolder"data"attheend,whichmeanstooIhadopenedit). Note:Ihaven'taddedtothescreenshotthatmention"Cedossierestvide"(=Emptyfolder).ThiscameonscreenautomaticallyfromtheW10utility(Frenchversion). MyAndroidversionis10(SamsungA40). AboutyoursuggestionoftryingcopyingafilefromthePCtothatspecificdirectory,IhavetotellyouthatIhadthefollowingthoughtlastnightbeforegoingtobed(I'mintheEUtimezonebutdidn'ttakethetimetoupdateyou: Ithoughtthat,maybe,justasupposition,Androiddidn'tgrantmearequiredREADauthorizationbecausethePCwasconsideredasbeinganotherApptryingtoaccessAICompanion'sstorage.Butnotgettinganyauthorizationalarm/errormessageleftmeinthedoubt. So,IhadtotesttheWRITEpermissiontoseewhetherI'ldreceiveanalarmthistimeonmyPC..andIdidexactlywhatyou'vesuggestedabove:I'vetriedtocopyanotherfilefrommyPCtothatdirectory..andtheresultwasthatitworkedstraightforwardMeaning,IdidseefrommyPCthe2ndfilenowresidinginAICompanion's"data"folder..andmyMITAIappsawit(andusedit)aswell..butallthisafterhavingcheckedbackthe"Legacymode"flagthough. Note:FromthePC,onlythe2ndfileisvisible.Fromthecell,bothfilesarevisible.So,AndroidandW10domanagethesetwofilesvisibilityalittlebitdifferently. ejb March15,2021,11:04am #16 Anke: IhavenoaccesstotheASDonadevicewithAndroid≥10. HereiswhatIcanseeonmycell,MIT'sfolderbeingoneamongstseveralothers: ..andhereiswhatIseeonmycell,speakingofAndroidversion,justincaseyourexperteyeswouldseesomething: image231×52715.9KB Inowneedtolearnmoreontheweb,butfearhavingtohandlepermissionsinallthevariousstepsusedtoupdateofmyappenvironment....butanyhelpisverywelcomeofcourse Anke April21,2021,6:35am #17 @ejbTrythisaiaonyourdevice: (EDIT:aiaremoved) IdownloadedthevideofromGoogleDrivetwice(Pixel2XL,Android11): grafik989×19113.7KB Blocks grafik1265×100077.7KB HOWTO:GetApplicationSpecificDirectory-ASD(whereoneexists)withoutExtensions Taifun March15,2021,9:29pm #18 ejb: So,fromthePC,myissuewasthatIhadnovisibilityonmyfile"Al_DVD-list-1col.prn",hencemy1stquestionaboutbeingornotabletoaccessano-READ-permission-external-private-storagefromaPC. thismightbebecauseof SomefoldersandfilesnotshowinguponPCwhenconnectedviaUSB 6.0-marshmallow,file-system answeredby ЈеднорукиКрстивоје on08:49PM-02Jan17UTC Taifun Tryingtopushthelimits!Snippets,TutorialsandExtensionsfromPuraVidaAppsbyTaifun. ejb May5,2021,9:19pm #19 First,thanksabenchtoeveryonewhotriestohelpmeoutonthatfilequestion (I'llread/playthegiveninfoandvideolaterwhenI'vetime) Second:I'minthemiddleofseveralthingsinmylifethatdon'tletmeenoughtimerightnowtoworkonmyapp,so,I'vebecomeparticularlyslowandunresponsivetoyouranswers/advices.. ..butIdorememberhavinganotherurgentquestion,thisoneaboutsettingtheexact"Picture"todisplayasan"Image"(UserInterface).Inthatcase,thereisno"Legacymode"flagliketheoneforREAD_filesandIgotstuckwithAndroid10(BTW,I'monAndroid11now).Sincemyapphastopicktherightimagefileoutofhundreds,andthatIaddnewimagefilesfromtimetotimetothelist,IneedtospecifythepathtothatimagefilefortheSET_PicturecommandasimilarwaytospecifyingthepathtoafilefortheREAD_FROMcommande. So,dowehaveasimilarworkaroundlikethe"Legacymode"forspecifyinganimagefilepaththistime? TIMAI2 May5,2021,9:29pm #20 AreyoutargetingAndroid>=10now(only)? Whereareyourimagefileslocatedonthedevice?(Android>=10?)



請為這篇文章評分?