Data and file storage overview | Android Developers

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

Android provides two types of physical storage locations: internal storage and external storage. On most devices, internal storage is smaller than external ... Platform AndroidStudio GooglePlay Jetpack Kotlin Docs Games Language English BahasaIndonesia Español–AméricaLatina Português–Brasil 中文–简体 日本語 한국어 Signin Documentation Overview Guides Reference Samples Design&Quality Platform AndroidStudio GooglePlay Jetpack Kotlin Docs Overview Guides Reference Samples Design&Quality Games AppBasics Introduction BuildyourfirstappOverviewCreateanAndroidprojectRunyourappBuildasimpleuserinterfaceStartanotheractivity Appfundamentals AppresourcesOverviewHandleconfigurationchanges LocalizationLocalizeyourappTestyourappwithpseudolocalesUnicodeandinternationalizationsupportLanguageandlocaleresolutionComplexXMLresources ResourcetypesOverviewAnimationColorstatelistDrawableLayoutMenuStringStyleFontMoretypes AppmanifestfileOverview Devices DevicecompatibilityOverviewScreencompatibilityoverviewSupportdifferentpixeldensitiesSupportdisplaycutoutsDeclarerestrictedscreensupport MultipleAPKsupportOverviewCreatemultipleAPKsfordifferentAPIlevelsCreatemultipleAPKsfordifferentscreensizesCreatemultipleAPKsfordifferentGLtexturesCreatemultipleAPKswithseveraldimensionsSupportdifferentlanguagesandculturesSupportdifferentplatformversionsFiltersonGooglePlay Tablets,largescreens,andfoldablesGetstartedwithlargescreens BuildresponsiveUIsSupportdifferentscreensizesNavigationforresponsiveUIsMigrateyourUItoresponsivelayoutsActivityembeddingMulti-windowsupportInputcompatibilityonlargescreens BuildforfoldablesLearnaboutfoldablesMakeyourappfoldawareTestyourapponfoldables WearGetstartedPrinciplesofWearOSdevelopmentUpgradetothelatestversionofWearOSWearOSversusmobiledevelopmentSetupJetpackComposeonWearOSUseJetpackComposeonWearOSWearOSdeveloperpathwayOngoingActivitiesWearOSuserinterfaceTilesExposedatatocomplications GettingstartedCreateandrunawearableappDebugaWearOSappCaptureWearUIscreenshotsAppearinRecentsandAppResume OverlaysOverviewUsetheWearUIlibraryHandledifferentwatchshapesScreenoptionsCreatelistsNavigationExitfullscreenactivitiesonWearShowconfirmationsPlayingaudioonwearablesWetmodeKeepyourappvisibleonWearAuthenticationStandaloneapp NotificationsNotificationsonWearOSBridgingoptionsfornotifications HandlingdataSendandsyncdataonWearOSNetworkaccessandsynconWearOSAccesstheWearableDataLayerTransferassetsSendandreceivemessagesHandledatalayereventsSyncdataitemswiththeDataLayerAPIRequestpermissionsDetectlocation UserinputPhysicalbuttonsRotaryinputCreateinputmethodeditorsinWearVoice WatchFaceStudioWatchFaceStudioKeyboardshortcutsManageaWatchFaceStudioprojectCreateawatchfacewithWatchFaceStudioBuildcomplicationsinWatchFaceStudioTagexpressionsLanguagesettingsAlways-oninWatchFaceStudioGyroeffectsBuildanduploadfromWatchFaceStudioTestyourwatchfaceFAQ HealthservicesOverviewActivedataandexercisePassivedataupdatesUsesyntheticdataprovidersHealthPlatformAPI DesignIntroductionDesignprinciplesGettingstartedInteractiontypesNotificationsComplicationsTilesOverlaysOngoingactivitiesConfirmationoverlayDisconnectionindicatorsPermissionmessagesSelectioncontrolsLaunchandlatencyNavigationPermissionsSigninHardwarebuttonsColorTypographyIconsDownloads ComponentsWearMaterialThemingButtonsChipsTogglechipsCardsListsCurvedtextsSwipetodismissScrollindicatorsPickersPageviewersSlidersProgressindicator CreatingwatchfacesOverviewDesignwatchfacesBuildawatchfaceserviceDrawwatchfacesWatchfacecomplicationsAddingcomplicationstoawatchfaceCreatinginteractivewatchfacesProvideconfigurationactivitiesAddresscommonissuesImproveperformacewithhardwareaccelerationOptimizeperformanceandbatterylifeWearappqualityPackageWearOSappsDistributetoWearOSCreateWearOSappsforChinaWearOSreleasenotes AndroidTVOverview BuildTVAppsOverviewGetstartedwithTVappsAndroidXTVlibrariesHandleTVhardwareManageTVcontrollersBuildTVlayoutsOn-screenkeyboardCreateTVnavigationBestpracticesfordrivingengagementonGoogleTV BuildTVplaybackappsOverviewCreateacatalogbrowserProvideacardviewBuildadetailsviewUseLeanbacktransportcontrolsPlaybackcontrolsonTVDisplayaNowPlayingcardAddaguidedstepIntroducefirst-timeuserstoyourappEnablebackgroundplaybackAudiocapabilitiesManageframerates HelpusersfindcontentonTVOverview RecommendTVcontentOverviewChannelsonthehomescreenVideoprogramattributesAudioprogramattributesGameprogramattributes WatchNextAddprogramsAttributesGuidelinesforappdevelopersGuidelinesforTVprovidersPreviewvideosRecommendationsinAndroidNandearlierMakeTVappssearchableSearchwithinTVApps BuildTVgamesOverviewUseStreamProtectforlatency-sensitivestreamingapps BuildTVinputservicesOverviewDevelopaTVinputserviceWorkwithchanneldataManageTVuserinteractionSupporttime-shiftingSupportcontentrecordingTVAppschecklist TVAccessibilityAccessibilitybestpracticesTalkBackevaluationexamplesAdoptsystemcaptionsettingsCustomviewaccessibilitysupportCustomviewaccessibilitysampleAndroid12DeveloperPreviewforTV AndroidforCarsOverview BuildmediaappsforcarsBuildmediaappsforcarsAddsupportforAndroidAutoAddsupportforAndroidAutomotiveOSBuildmessagingappsforAndroidAuto Buildnavigation,parking,andchargingappsforcarsUsingtheAndroidforCarsAppLibraryBuildparkingandchargingappsforcarsBuildnavigationappsforcarsAddsupportforAndroidAutoTestAndroidappsforcarsGooglePlayservicesNotificationsonAndroidAutomotiveOS AndroidThingsOverviewPlatformdifferencesGoogleservices SupportedhardwareOverviewNXPi.MX7DRaspberryPi3 AdvancedsetupOverviewManuallyflashanimageRecoveradeviceConnectingtoWi-Fiwithadb Buildapps CreateaThingsappOverviewCreateaprojectConnectthehardwareInteractwithperipheralsIntegrateperipheraldrivers CommunicatewithwirelessdevicesBluetoothLoWPAN ConfiguredevicesSettingsUpdates InteractwithperipheralsOverviewGPIOPWMI2CSPIUARTNativePIOCLItoolIntegratenativecode Builduser-spacedriversOverviewLocationInputSensorsLoWPANSamples ManagedevicesOverviewCreateaproductConfigureaproduct CreateabuildOverviewManageapps PushanupdateOverviewAutomaticupdatesMonitoranalytics TermsConsoleTermsofServiceSDKLicenseAgreementAndroidThingsConsole ChromeOSdevicesOverviewBuildingappsforChromeOSOptimizingAppsforChromeOSPreparingyourdevelopmentenvironmentAppManifestCompatibilityforChromebooksChromeOSDeviceSupportforAppsAppRenderingDifferencesonChromebooksWindowmanagementAdaptingGamesonChromeOSSmoothanimationonChromeOSTestCasesforAndroidAppsonChromeOS Apparchitecture Introduction Guidetoapparchitecture ArchitectureComponents UIlayerlibraries ViewbindingOverviewMigratefromKotlinsyntheticstoviewbinding DatabindinglibraryOverviewGetstartedLayoutsandbindingexpressionsWorkwithobservabledataobjectsGeneratedbindingclassesBindingadaptersBindlayoutviewstoArchitectureComponentsTwo-waydatabinding Lifecycle-awarecomponentsHandlelifecyclesViewModelLiveDataSaveUIstatesSavedStatemoduleforViewModelUseKotlincoroutineswithlifecycle-awarecomponents PagingLibraryOverviewLoadanddisplaypageddataPagefromnetworkanddatabaseTransformdatastreamsManageandpresentloadingstatesTestyourPagingimplementationMigratetoPaging3 Paging2OverviewDisplaypagedlistsLoadpageddata DatalayerlibrariesDataStore WorkManagerOverviewGettingStarted How-ToGuidesDefiningyourWorkRequestsWorkstatesManagingworkObservingintermediateWorkerprogressChainingworktogetherTestingWorkerimplementationIntegrationtestswithWorkManagerDebuggingWorkManager AdvancedConceptsConfigurationandInitialization ThreadinginWorkManagerOverviewThreadinginWorkerThreadinginCoroutineWorkerThreadinginRxWorkerThreadinginListenableWorkerSupportforlong-runningworkersMigratingfromFirebaseJobDispatcherMigratingfromGCMNetworkManager Appentrypoints ActivitiesIntroductiontoactivitiesTheactivitylifecycleActivitystatechangesTestyouractivitiesTasksandbackstackProcessesandapplifecycleParcelablesandbundlesLoadersRecentsscreenRestrictionsonstartingactivitiesfromthebackground AppshortcutsOverviewCreateshortcutsAddcapabilitiesManageshortcutsBestpracticesforshortcuts AppnavigationPrinciplesofnavigationDesignfordifferentformfactorsHandleconfigurationchanges NavigationcomponentOverviewGettingstartedCreatedestinationsDesignnavigationgraphsNestedgraphsGlobalactionsNavigatetoadestinationConditionalnavigationPassdatabetweendestinationsCreateadeeplinkforadestinationAnimatetransitionsbetweendestinationsUpdateUIcomponentswithNavigationUIKotlinDSLInteractprogrammaticallyNavigatewithfeaturemodulesBestpracticesformulti-moduleprojectsTestnavigationAddnewdestinationtypesMigratetotheNavigationcomponent FragmentsOverviewCreateafragmentFragmentmanagerFragmenttransactionsAnimatetransitionsbetweenfragmentsFragmentlifecycleSavingstatewithfragmentsCommunicatewithfragmentsWorkingwiththeappbarDisplayingdialogswithDialogFragmentDebugyourfragmentsTestyourfragments ApplinksOverviewEnablinglinkstoappcontentVerifyapplinksCreateapplinksforinstantappsCreateswipeviewswithtabsusingViewPagerCreateswipeviewswithtabsusingViewPager2Providecustombacknavigation DependencyinjectionOverviewManualdependencyinjectionDependencyinjectionwithHiltHiltinmulti-moduleappsHiltandJetpackintegrationsHilttestingguideHiltandDaggerannotationscheatsheet DaggerDaggerbasicsUsingDaggerinAndroidappsUsingDaggerinmulti-moduleapps AppStartup Coretopics AppcompatibilityOverviewCompatibilityframeworktoolsRestrictionsonnon-SDKinterfaces InteractwithotherappsOverviewSendingtheusertoanotherappGettingaresultfromanactivityAllowingotherappstostartyouractivity PackagevisibilityOverviewKnowwhichpackagesarevisibleautomaticallyDeclarepackagevisibilityneedsFulfillcommonusecasesTestpackagevisibility IntentsandintentfiltersOverviewCommonintents UserinterfaceOverview LayoutsOverviewBuildaresponsiveUIwithConstraintLayout AddmotiontoyourlayoutwithMotionLayoutOverviewCarouselwithMotionLayoutMotionLayoutexamples MotionLayoutXMLreferenceOverviewCreatealistwithRecyclerViewAdvancedRecyclerViewcustomizationCreateacard-basedlayoutCreateatwopanelayout ImprovinglayoutperformanceOverviewOptimizinglayouthierarchiesRe-usinglayoutswithDelayedloadingofviewsLinearlayoutAdapterviewRelativelayout CustomviewcomponentsOverviewCreatingacustomviewclassImplementingcustomdrawingMakingtheviewinteractiveOptimizingtheviewDesigningforfoldables LookandfeelMaterialdesignStylesandthemesDarkthemeRoundedcornersAdaptiveiconsAddafloatingactionbuttonCreateshadowsandclipviews TextAutosizingTextViewsDownloadablefontsFontsinXML EmojiSupportmodernemojiEmojicompatibilityMagnifierwidgetSpansButtonsCheckboxesRadiobuttonsTogglebuttonsSpinnersPickersTooltips NotificationsOverviewCreateanotificationCreateanexpandablenotificationDisplaytime-sensitivenotificationsStartanactivityfromanotificationCreateagroupofnotificationsCreateandmanagenotificationchannelsModifyanotificationBadgeCreateacustomnotification SplashscreensOverviewMigrateyourexistingsplashscreenConversationsBubbles AddtheappbarOverviewSetuptheappbarAddandhandleactionsAddanupactionUseactionviewsandactionproviders ControlthesystemUIvisibilityOverviewDimthesystembarsHidethestatusbarHidethenavigationbarEnablefullscreenmodeRespondtoUIvisibilitychanges Supportingswipe-to-refreshOverviewAddingswipe-to-refreshtoyourappRespondingtoarefreshgestureToastsoverview Pop-upmessagesoverviewOverviewBuildanddisplayapop-upmessageAddanactiontoamessageDialogsMenus SettingsOverviewOrganizeyoursettingsCustomizeyoursettingsUsesavedvaluesBuildahierarchyincodeHandleotherformfactorsPreferencecomponentsandattributes SearchOverviewCreatingasearchinterfaceAddingrecentquerysuggestionsAddingcustomsuggestionsSearchableconfiguration AddingsearchfunctionalityOverviewSettingupthesearchinterfaceStoringandsearchingfordataRemainingbackwardcompatibleCopyandpasteDraganddropPicture-in-picturesupport Creatingbackward-compatibleUIsOverviewAbstractingthenewAPIsProxyingtothenewAPIsCreatinganimplementationwitholderAPIsUsingtheversion-awarecomponentDevicecontrol HomechannelsformobileappsOverviewMediaHomeBooksMediaHomeVideo AppwidgetsOverviewCreateasimplewidgetEnhanceyourwidgetCreateanadvancedwidgetUsewidgetcollectionsProvideflexiblewidgetlayoutsEnablewidgetconfigurationBuildanappwidgethost Animations&transitionsOverviewIntroductiontoanimationsPropertyanimationoverviewAnimatedrawablegraphicsRevealorhideaviewusinganimationMoveaviewusinganimationMoveaviewusingaflinganimationEnlargeaviewusingazoomanimationAnimatemovementusingspringphysicsAutoanimatelayoutupdatesAnimatelayoutchangesusingatransitionCreateacustomtransitionanimationStartanactivityusingananimationSlidebetweenfragmentsusingViewPagerSlidebetweenfragmentsusingViewPager2MigratefromViewPagertoViewPager2Additionalresources Images&graphicsOverviewDrawablesoverviewVectordrawablesoverviewHandlingbitmapsSelectingcolorswiththepaletteAPIReducingimagedownloadsizesHardwareaccelerationOpenGLES DisplayinggraphicswithOpenGLESOverviewBuildinganOpenGLESenvironmentDefiningshapesDrawingshapesApplyingprojectionandcameraviewsAddingmotionRespondingtotouchevents RenderingOverviewReducingoverdrawPerformanceandviewhierarchiesAnalyzingwithprofileGPUrenderingEnhancinggraphicswithwidecolorcontent Audio&videoAudio&videooverviewMediacontrolsSupportedmediaformatsMediacodecs MediaapparchitectureMediaapparchitectureoverviewUsingamediasession BuildinganaudioappAudioappoverviewBuildingamediabrowserserviceBuildingamediabrowserclientMediasessioncallbacksUsingthemediacontrollertestapp BuildingavideoappVideoappoverviewBuildingavideoplayeractivityMediasessioncallbacksCompatiblemediatranscodingRespondingtomediabuttonsHandlingchangesinaudiooutputManageaudiofocus TheGoogleAssistantTheGoogleAssistantandmediaappsMediaappsonGoogleAssistantdrivingmode RoutingbetweendevicesRoutingoverviewMediaRouteroverviewMediaRouteProvideroverviewControlamplitudewithVolumeShaperMediaPlayeroverviewMediaRecorderoverviewExoPlayerSharingaudioinputCapturevideoandaudioplaybackFramerateBestpracticesforsharingvideoAdditionalResourcesforMedia ServicesOverviewForegroundservicesBoundservicesAIDLoverview BackgroundtasksOverviewBackgroundthreadsBackgroundoptimizations BroadcastsOverviewImplicitBroadcastExceptions ManagedeviceawakestateOverviewKeepthedeviceawakeSchedulealarms PermissionsOverviewEvaluatewhetheryourappneedspermissionsDeclareapppermissionsRequestapppermissionsExplainaccesstomoresensitiveinformationApppermissionsbestpracticesPermissionsusedonlyindefaulthandlersRestrictinteractionswithotherappsDefinecustompermissions Appdata&filesOverviewStorageoverviewSavetoapp-specificstorage SavetosharedstorageOverviewMediaDocumentsandotherfilesDatasetsManageallfilesonastoragedeviceSavekey-valuedata SavedatainalocaldatabaseOverviewDefinedatausingentitiesAccessdatausingDAOsDefinerelationshipsbetweenobjectsWriteasynchronousDAOqueriesCreateviewsintoadatabasePrepopulateyourdatabaseMigrateyourdatabaseTestanddebugyourdatabaseReferencecomplexdataMigratefromSQLitetoRoomSavedatausingSQLiteStorageusecasesandbestpractices SharingsimpledataOverviewSendingsimpledatatootherappsReceivingsimpledatafromotherapps SharingfilesOverviewSettingupfilesharingSharingafileRequestingasharedfileRetrievingfileinformation SharingfileswithNFCOverviewSendingfilestoanotherdeviceReceivingfilesfromanotherdevice PrintingfilesOverviewPrintingphotosPrintingHTMLdocumentsPrintingcustomdocuments ContentprovidersOverviewContentproviderbasicsCreatingacontentproviderOpenfilesusingstorageaccessframeworkCreateacustomdocumentproviderAppinstalllocation Userdata&identityOverviewAddsign-inworkflowShowabiometricauthenticationdialog AutofillframeworkOverviewOptimizeyourappforautofillBuildautofillservicesIntegrateautofillwithkeyboardsIdentifydeveloper-ownedappsReviewhowyourappcollectsandsharesuserdataAuditdataaccessGetauser-resettableadvertisingIDCalendarprovideroverview ContactsproviderOverviewRetrievingalistofcontactsRetrievingdetailsforacontactModifyingcontactsusingintentsDisplayingthequickcontactbadgeAccounttransfer DatabackupOverviewBackupuserdataBackupkey-valuepairsTestbackupandrestoreBestpracticesforuniqueidentifiers RememberandauthenticateusersOverviewRememberyouruserAuthenticatetoOAuth2servicesCreateacustomaccounttype UserlocationOverviewRequestlocationpermissionsGetthelastknownlocationChangelocationsettingsRequestlocationupdatesAccesslocationinthebackgroundCreateandmonitorgeofencesDetectwhenusersstartanactivityOptimizelocationforbatteryTestlocationworkflowsMigratetolocationandcontextAPIsAddmaps Touch&inputOverviewInputevents UsingtouchgesturesOverviewDetectcommongesturesTracktouchandpointermovementsAnimateascrollgestureSupportnavigationgesturesImplementedge-to-edgeHandlemulti-touchgesturesDragandscaleManagetoucheventsinaViewGroup HandlingkeyboardinputOverviewSpecifyingtheinputmethodtypeHandlinginputmethodvisibilitySupportingkeyboardnavigationHandlingkeyboardactions SupportinggamecontrollersOverviewHandlingcontrolleractionsSupportingcontrollersacrossAndroidversionsSupportingmultiplegamecontrollers InputmethodeditorsCreatinganinputmethodImagekeyboardReceiverichcontentSpellingchecker CameraXOverviewCameraXarchitectureConfigurationPreviewImageanalysisImagecaptureVideocaptureExtensionsAPITransformoutputUsecaserotationsCameraXdevices Camera2OverviewCameracapturesessionsandrequestsCameraenumerationUsemultiplecamerastreamssimultaneouslyCamerapreviewonlargescreensMulti-CameraAPIExtensionsAPI CameraOverviewTakingphotosRecordingvideosControllingthecameraCameraAPI SensorsOverviewSensorsoverviewMotionsensorsPositionsensorsEnvironmentsensorsRawGNSSmeasurements ConnectivityOverview PerformingnetworkoperationsOverviewConnecttothenetworkManagenetworkusageReadingnetworkstateOptimizenetworkdatausageParseXMLdata TransmitnetworkdatausingVolleyOverviewSendasimplerequestSetupRequestQueueMakeastandardrequestImplementacustomrequest PerformnetworkoperationsusingCronetOverviewSendasimplerequestCronetrequestlifecycle Reference org.chromium.netOverviewCallbackException CronetEngineOverview CronetEngine.BuilderOverviewLibraryLoaderCronetExceptionInlineExecutionProhibitedExceptionNetworkExceptionQuicExceptionUploadDataProviderUploadDataProvidersUploadDataSink UrlRequestOverviewBuilderCallbackStatusStatusListener UrlResponseInfoOverviewHeaderBlockEnhanceyourappswith5GBuildclient-serverapplicationswithgRPC TransferringdatawithoutdrainingthebatteryOverviewOptimizedownloadsforefficientnetworkaccessMinimizetheeffectofregularupdatesAvoidredundantdownloadsModifypatternsbasedontheconnectivitytype ReducenetworkbatterydrainOverviewCollectingnetworktrafficdataAnalyzingdatatrafficOptimizeuser-initiatednetworkuseOptimizeapp-initiatednetworkuseOptimizeserver-initiatednetworkuseOptimizinggeneralnetworkuse TransferdatausingSyncAdaptersOverviewCreateaStubAuthenticatorCreateaStubContentProviderCreateaSyncAdapterRunaSyncAdapter BluetoothOverviewSetupBluetoothFindBluetoothdevicesConnectBluetoothdevicesTransferBluetoothdataBluetoothpermissionsBluetoothprofilesCompaniondevicepairing BluetoothLowEnergyOverviewFindBLEdevicesConnecttoaGATTserverTransferBLEdata NFCOverviewNFCbasicsAdvancedNFCHost-basedcardemulationoverview TelecomOverviewBuildacallingappPreventcallerIDspoofingTelephonyIDs Wi-FiWi-FiscanningoverviewWi-Fipeer-to-peerWi-FiAwareoverviewWi-FilocationwithRTTLocalOnlyHotspot Wi-FiinfrastructureWi-FiinfrastructureoverviewWi-FisuggestionAPIforinternetconnectivityWi-FiNetworkRequestAPIforpeer-to-peerconnectivityPasspointSavenetworksandPasspointconfigurations USBOverviewAccessoryoverviewHostoverviewVPNSessioninitiationprotocoloverview DiscoverandconnectOverviewUsenetworkservicediscoveryCreateP2PconnectionswithWi-FiUseWi-FiP2PforservicediscoveryWi-FiEasyConnectOpenMobileAPIreadersupport RenderscriptOverviewAdvancedRenderScriptMigratefromRenderScript RuntimeAPIreferenceOverviewNumericaltypesObjecttypesConversionfunctionsMathematicalconstantsandfunctionsVectormathfunctionsMatrixfunctionsQuaternionfunctionsAtomicupdatefunctionsTimefunctionsandtypesAllocationdataaccessfunctionsObjectcharacteristicsfunctionsKernelinvocationfunctionsandtypesInput/outputfunctionsDebuggingfunctionsGraphicsfunctionsandtypesIndex Web-basedcontentOverviewBuildingwebappsinWebViewManagingWebViewobjectsLoadlocalcontentDarkenwebcontentUserprivacyinWebViewcrashreportingMigratingtoWebViewinAndroid4.4SupportingdifferentscreensinwebappsDebuggingwebappsBestpracticesforwebapps AndroidAppBundlesOverviewConfigurethebasemoduleBuildandtestyourappbundleAddcodetransparencyTheappbundleformatFrequentlyaskedquestions GooglePlayGooglePlayBillingPlayCoreLibrary PlayAssetDeliveryOverviewIntegrateassetdelivery(Kotlin&Java)Integrateassetdelivery(native)Integrateassetdelivery(Unity)TargettexturecompressionformatsTestassetdelivery PlayFeatureDeliveryOverviewConfigureinstall-timedeliveryConfigureconditionaldeliveryConfigureon-demanddeliveryOn-demanddeliverybestpracticesConfigureinstantdeliveryAdditionalresources In-appreviewsOverviewIntegrateusingKotlinorJavaIntegrateusingnativecodeIntegrateusingUnityTestin-appreviews In-appupdatesOverviewSupportin-appupdates(KotlinorJava)Supportin-appupdates(Native)Supportin-appupdates(Unity)Testin-appupdates GooglePlayInstantOverviewofGooglePlayInstant GetstartedwithinstantappsCreateaninstant-enabledappbundleUXbestpracticesforapps GetstartedwithinstantgamesOverviewUnitypluginUXbestpracticesforgamesMigratetoAndroidAppBundlesImplementclouddeliveryofassetsSupportGooglePlayGamesServicesInstantPlaygamesInstantPlaygameschecklistReducethesizeofyourinstantapporgameAddadstoyourinstantapporgameProvidemultipleentrypoints IntegratewithFirebaseAddGoogleAnalyticsforFirebasetoyourinstantappUseFirebaseDynamicLinkswithinstantappsTechnicalrequirementschecklistGooglePlayInstantpolicy ResourcesReferenceCodesamplesSDKreleasenotesInstantAppIntents SupportKnownissuesStackOverflowPlayDeveloperAPI PlayInstallReferrerOverview PlayInstallReferrerLibraryOverviewReferenceReleasenotesPlayInstallReferrerAPIPlayIntegrityAPI ApplicationLicensingOverviewLicensingOverviewSettingUpforLicensingAddingServer-SideVerificationAddingClient-SideVerificationLicensingReferenceAPKExpansionFiles AppActions SlicesOverviewGettingStartedSlicetemplates On-devicesearch Games ToolsAndroidStudio AndroidGameDevelopmentExtensionforVisualStudioOverviewQuickstartConfigureaprojectDebuggerMeasureappperformanceSamplesReleasenotesAndroidNDK AndroidGPUInspectorOverviewQuickstart SystemprofilingOverviewViewasystemprofile AnalyzeasystemprofileFrameprocessingtimesMemoryefficiencyTexturememorybandwidthusageVertexmemorybandwidthusageThreadscheduling GPUperformancecountersArmMaliQualcommAdrenoImaginationPowerVR FrameprofilingOverview AnalyzeaframeprofileMostexpensiverenderpassesVertexformatsShaderperformance FrameProfilerUIPerformancepaneCommandspaneFramebufferpaneGeometrypaneReportpaneShaderpaneMemorypaneStatepaneTexturespaneTexturepanePipelineviewpaneSupportedVulkanextensionsTroubleshoot CustomizeorportgameenginesOverview GettingstartedIntegrateGameActivityConfiguregraphicsUnderstandAndroidgameloops ProcessinputeventsAddtouchsupportSupporttextinput SupportgamecontrollersOverviewUsethegamecontrollerlibraryUsecustomcontrollerdevicemappingsAddmousesupportSupportsensorinput AchieveproperframepacingOverview FramepacinginOpenGLESIntegrateUpdateyourbuildsettingsAddframepacingfunctionsVerifyframepacingimprovement FramepacinginVulkanIntegrateUpdateyourbuildsettingsAddframepacingfunctionsVerifyframepacingimprovementReference IntegrateAndroidPerformanceTunerOverviewRunthedemoappEnabletheAPIUpdateyourbuildsettingsDefineannotations,fidelityparameters,andsettingsAddframetimingfunctionsAddloadingtimerecordingfunctionsValidate,package,andpublishtheAPKTroubleshootcommonerrorsAdvancedusageReference OutputaudioOverviewUpdatebuildsettingsUseOboeCodesamplesFullOboeguide ManagememoryOverviewDebugnativememoryuseDeliverassetsDetectanddiagnosecrashes UseprebuiltorturnkeygameenginesOverview DevelopwithDefoldInstallandconfigureprojectsforAndroidSupportmultipleformfactorsandscreensizesExporttoAndroid DevelopwithGodotInstallandconfigureprojectsforAndroidGodotrendereroptionsSupportmultipleformfactorsandscreensizesExporttoAndroid DevelopwithUnityOverviewCreateanAndroidAppBundlewithUnityIntegratePlayAssetDeliveryUnityLightinginMobileGames UseAndroidPerformanceTunerOverviewEnabletheAPIIntegratethepluginInitializethelibraryandverifyoperationDefineannotations,fidelityparameters,andqualitylevelsAddloadingtimerecordingfunctionsRunthemonitorappReviewandpublishTroubleshootcommonerrorsReferenceDevelopwithUnrealRequestinguserpermissionsSecureyourgame Gamebestpractices MaximizedeviceavailabilitySupport64-bitarchitecturesDevelopgamesforallscreensSign-in,savegames,andmorewithPlayGamesServices ArtassetsGeometrybestpractices OpenGLandVulkanDeviceorientationefficientlyinVulkanVertexdatamanagement GameModeOverviewOptimizewithGameModeAPIGameModeinterventions OptimizeCPU,memory,andgraphicstoolsAndroidPerformanceTuner GuidesImprovegameperformanceReducegamesize DistributeOverviewReleasewithGooglePlayInstantPlayasyoudownload Bestpractices TestingOverviewFundamentalsoftestingSetupproject BuildingeffectiveunittestsOverviewBuildinglocalunittestsBuildinginstrumentedunittests AutomatingUItestsOverviewTestingUIforasingleappTestingUIformultipleapps TestingappcomponentintegrationsOverviewTestingyourserviceTestingyourcontentproviderTestingUIperformance EspressoOverviewSetupinstructionsBasicsRecipesMultiprocessAccessibilitycheckingListsIntentsWebIdlingresourceCheatsheetAdditionalresourcesUIAutomatorAppCrawlerJUnit4RulesAndroidJUnitRunnerReleasenotesAdditionalresources PerformanceOverviewPerformanceclass AndroidVitalsOverviewStuckPartialWakeLocksExcessiveWakeupsExcessiveBackgroundWi-FiScansExcessiveBackgroundNetworkUsageANRsCrashesSlowRenderingFrozenFramesPermissionDenialsAppStartupTimeAppStandbyBucketsAppHibernationProcessesandThreadsOverviewBetterPerformancethroughThreading OptimizingforBatteryLifeOverviewOptimizeforDozeandAppStandbyMonitorthebatterylevelandchargingstateMonitorconnectivitystatusandconnectionmeteringDetermineandmonitorthedockingstateandtypePowermanagementrestrictionsProfilebatteryusagewithBatterystatsandBatteryHistorianAnalyzepowerusewithBatteryHistorianTestingpower-relatedissuesReduceyourappsize ManagememoryOverviewofMemoryManagemementMemoryAllocationamongProcessesManageYourApp'sMemory SystemtracingOverviewCaptureatracefromthecommandlineCaptureatraceonadeviceNavigateareportDefinecustomeventsCustomtraceeventsinnativecodeInspectGPUrenderingDesigningforSeamlessnessKeepingYourAppResponsivePerformanceTipsSMPPrimerforAndroidVerifyingAppBehaviorontheAndroidRuntime(ART) AccessibilityOverview BuildandtestappsforaccessibilityMakeappsmoreaccessiblePrinciplesforimprovingappaccessibilityTestyourapp'saccessibility AdvancedtopicsMakecustomviewsmoreaccessibleCreateyourownaccessibilityserviceAdditionalresources PrivacyPrivacybestpractices SecurityAppsecuritybestpracticesSecuritytipsSecuritywithdataSecuritywithdataacrossadditionalAndroidversionsSecuritywithHTTPSandSSLNetworksecurityconfigurationUpdatingyoursecurityprovidertoprotectagainstSSLexploits ProtectingagainstsecuritythreatswithSafetyNetOverviewSafetyNetAttestationAPISafetyNetSafeBrowsingAPISafetyNetreCAPTCHAAPISafetyNetVerifyAppsAPICryptographyAndroidKeystoreSystemVerifyinghardware-backedkeypairswithkeyattestationAndroidProtectedConfirmationSupportingDirectBootRunningembeddedDEXcodeAppsecurityimprovementprogram BuildforBillionsOverviewConnectivityDevicecapabilityDatacostBatteryconsumptionUIandcontent BuildforEnterpriseOverviewDeveloperguideWorkprofilesSetupmanagedconfigurations AppfeedbackSendappfeedbacktoEMMsTestappfeedbackWorkcontactsDevicemanagementpolicies DevicemanagementOverviewBuildadevicepolicycontroller DedicateddevicesOverviewLocktaskmodeMultipleusersCookbookDevicecontrolNetworkingandtelephonySecuritySystemupdatesNetworkactivitylogging AndroidversionsOverviewAndroid12Android11Android10Android9Android8.0Android7.0Deviceadministration AndroidDevelopers Docs Guides Dataandfilestorageoverview Androidusesafilesystemthat'ssimilartodisk-basedfilesystemsonother platforms.Thesystemprovidesseveraloptionsforyoutosaveyourappdata: App-specificstorage:Storefilesthataremeantforyourapp'suseonly, eitherindedicateddirectorieswithinaninternalstoragevolumeordifferent dedicateddirectorieswithinexternalstorage.Usethedirectorieswithin internalstoragetosavesensitiveinformationthatotherappsshouldn'taccess. Sharedstorage:Storefilesthatyourappintendstosharewithother apps,includingmedia,documents,andotherfiles. Preferences:Storeprivate,primitivedatainkey-valuepairs. Databases:StorestructureddatainaprivatedatabaseusingtheRoom persistencelibrary. Thecharacteristicsoftheseoptionsaresummarizedinthefollowingtable: Typeofcontent Accessmethod Permissionsneeded Canotherappsaccess? Filesremovedonappuninstall? App-specific files Filesmeantforyourapp'suseonly Frominternalstorage,getFilesDir()or getCacheDir()Fromexternalstorage, getExternalFilesDir()or getExternalCacheDir() NeverneededforinternalstorageNotneededforexternal storagewhenyourappisusedondevicesthatrunAndroid4.4(APIlevel19) orhigher No Yes Media Shareablemediafiles(images,audiofiles,videos) MediaStoreAPI READ_EXTERNAL_STORAGEwhenaccessingotherapps'fileson Android 11(APIlevel 30)orhigher READ_EXTERNAL_STORAGEorWRITE_EXTERNAL_STORAGE whenaccessingotherapps'filesonAndroid 10(APIlevel29) PermissionsarerequiredforallfilesonAndroid9(APIlevel28)or lower Yes,thoughtheotherappneedstheREAD_EXTERNAL_STORAGE permission No Documentsand otherfiles Othertypesofshareablecontent,includingdownloadedfiles StorageAccessFramework None Yes,throughthesystemfilepicker No App preferences Key-valuepairs Jetpack Preferenceslibrary None No Yes Database Structureddata Roompersistencelibrary None No Yes Thesolutionyouchoosedependsonyourspecificneeds: Howmuchspacedoesyourdatarequire? Internalstoragehaslimitedspaceforapp-specificdata.Useothertypesof storageifyouneedtosaveasubstantialamountofdata. Howreliabledoesdataaccessneedtobe? Ifyourapp'sbasicfunctionalityrequirescertaindata,suchaswhenyourapp isstartingup,placethedatawithininternalstoragedirectoryoradatabase. App-specificfilesthatarestoredinexternalstoragearen'talwaysaccessible becausesomedevicesallowuserstoremoveaphysicaldevicethatcorrespondsto externalstorage. Whatkindofdatadoyouneedtostore? Ifyouhavedatathat'sonlymeaningfulforyourapp,useapp-specific storage.Forshareablemediacontent,usesharedstoragesothatotherappscan accessthecontent.Forstructureddata,useeitherpreferences(forkey-value data)oradatabase(fordatathatcontainsmorethan2columns). Shouldthedatabeprivatetoyourapp? Whenstoringsensitivedata—datathatshouldn'tbeaccessiblefromanyother app—useinternalstorage,preferences,oradatabase.Internalstoragehasthe addedbenefitofthedatabeinghiddenfromusers. Categoriesofstoragelocations Androidprovidestwotypesofphysicalstoragelocations:internalstorageand externalstorage.Onmostdevices,internalstorageissmallerthanexternal storage.However,internalstorageisalwaysavailableonalldevices,makingit amorereliableplacetoputdataonwhichyourappdepends. Removablevolumes,suchasanSDcard,appearinthefilesystemaspartof externalstorage.Androidrepresentsthesedevicesusingapath,suchas /sdcard. Caution:Theexactlocationofwhereyourfilescanbesavedmightvaryacross devices.Forthisreason,don'tusehard-codedfilepaths. Appsthemselvesarestoredwithininternalstoragebydefault.IfyourAPKsize isverylarge,however,youcanindicateapreferencewithinyourapp'smanifest filetoinstallyourapponexternalstorageinstead: ... Permissionsandaccesstoexternalstorage Androiddefinesthefollowingstorage-relatedpermissions: READ_EXTERNAL_STORAGE, WRITE_EXTERNAL_STORAGE, and MANAGE_EXTERNAL_STORAGE. OnearlierversionsofAndroid,appsneededtodeclarethe READ_EXTERNAL_STORAGEpermissiontoaccessanyfileoutsidetheapp-specific directoriesonexternalstorage. Also,appsneededtodeclaretheWRITE_EXTERNAL_STORAGEpermissiontowriteto anyfileoutsidetheapp-specificdirectory. MorerecentversionsofAndroidrelymoreonafile'spurposethanitslocation fordetermininganapp'sabilitytoaccess,andwriteto,agivenfile.In particular,ifyourapptargetsAndroid11(APIlevel30)orhigher,the WRITE_EXTERNAL_STORAGEpermissiondoesn'thaveanyeffectonyourapp's accesstostorage.Thispurpose-basedstoragemodelimprovesuserprivacy becauseappsaregivenaccessonlytotheareasofthedevice'sfilesystemthat theyactuallyuse. Android11introducestheMANAGE_EXTERNAL_STORAGEpermission,whichprovides writeaccesstofilesoutsidetheapp-specificdirectoryandMediaStore.To learnmoreaboutthispermission,andwhymostappsdon'tneedtodeclareitto fulfilltheirusecases,seetheguideonhowtomanageall filesonastoragedevice. Scopedstorage Togiveusersmorecontrolovertheirfilesandtolimitfileclutter,appsthat targetAndroid 10(APIlevel29)andhigheraregivenscopedaccessintoexternal storage,orscopedstorage,bydefault.Suchappshaveaccessonlytothe app-specificdirectoryonexternalstorage,aswellasspecifictypesofmedia thattheapphascreated. Note:Ifyourapprequestsastorage-relatedpermissionatruntime,the user-facingdialogindicatesthatyourappisrequestingbroadaccessto externalstorage,evenwhenscopedstorageisenabled. Usescopedstorageunlessyourappneedsaccesstoafilethat'sstoredoutside ofanapp-specificdirectoryandoutside ofadirectorythattheMediaStore APIscanaccess.Ifyoustoreapp-specificfilesonexternalstorage,youcan makeiteasiertoadoptscopedstoragebyplacingthesefilesinan app-specificdirectoryonexternal storage.Thatway,yourapp maintainsaccesstothesefileswhenscopedstorageisenabled. Toprepareyourappforscopedstorage,viewthestorageusecasesandbest practicesguide.Ifyourapphasanotheruse casethatisn'tcoveredbyscopedstorage,fileafeature request.Youcan temporarilyopt-outofusingscoped storage. Viewfilesonadevice Toviewthefilesstoredonadevice,useAndroidStudio'sDeviceFile Explorer. Additionalresources Formoreinformationaboutdatastorage,consultthefollowingresources. Videos PreparingforScopedStorage(AndroidDevSummit '19) ContentandcodesamplesonthispagearesubjecttothelicensesdescribedintheContentLicense.JavaisaregisteredtrademarkofOracleand/oritsaffiliates. Lastupdated2021-11-11UTC. [{ "type":"thumb-down", "id":"missingTheInformationINeed", "label":"MissingtheinformationIneed" },{ "type":"thumb-down", "id":"tooComplicatedTooManySteps", "label":"Toocomplicated/toomanysteps" },{ "type":"thumb-down", "id":"outOfDate", "label":"Outofdate" },{ "type":"thumb-down", "id":"samplesCodeIssue", "label":"Samples/codeissue" },{ "type":"thumb-down", "id":"otherDown", "label":"Other" }] [{ "type":"thumb-up", "id":"easyToUnderstand", "label":"Easytounderstand" },{ "type":"thumb-up", "id":"solvedMyProblem", "label":"Solvedmyproblem" },{ "type":"thumb-up", "id":"otherUp", "label":"Other" }] Twitter Follow@AndroidDevonTwitter YouTube CheckoutAndroidDevelopersonYouTube MoreAndroid Android AndroidforEnterprise Security Source News Blog Podcasts Discover Gaming MachineLearning Privacy 5G AndroidDevices Largescreens WearOS AndroidTV Androidforcars AndroidThings ChromeOSdevices Releases Android11 Android10 Pie Oreo Nougat Marshmallow Lollipop KitKat DocumentationandDownloads AndroidStudioguide Developersguides APIreference DownloadStudio AndroidNDK Support Reportplatformbug Reportdocumentationbug GooglePlaysupport Joinresearchstudies Android Chrome Firebase GoogleCloudPlatform Allproducts Privacy License Brandguidelines Getnewsandtipsbyemail Subscribe Language English BahasaIndonesia Español–AméricaLatina Português–Brasil 中文–简体 日本語 한국어



請為這篇文章評分?