As previously discussed, the Storage Access Framework considerably eases the process of integrating cloud based storage access into Android applications. Consisting of a picker user interface and a set of new intents, access to files stored on document providers such as Google Drive and Box can now be built into Android applications with relative ease.
With the basics of the Android Storage Access Framework covered in the preceding chapter, this chapter will work through the creation of an example application which uses the Storage Access Framework to store and manage files.
About the Storage Access Framework Example The Android application created in this chapter will take the form of a rudimentary text editor designed to create and store text files remotely onto a cloud based storage service. In practice, the example will work with any cloud based document storage provider that is compatible with the Storage Access Framework, though for the purpose of this example the use of Google Drive is assumed.
In functional terms, the application will present the user with a multi-line text view into which text may be entered and edited, together with a set of buttons allowing storage based text files to be created, opened and saved. 52.2 Creating the Storage Access Framework Example Create a new project in Android Studio, entering StorageDemo into the Application name field and ebookfrenzy.com as the Company Domain setting before clicking on the Next button.
On the form factors screen, enable the Phone and Tablet option and set the minimum SDK setting to API 19: Android 4.4 (KitKat). Continue to proceed through the screens, requesting the creation of an empty activity named StorageDemoActivity with a corresponding layout named activity_storage_demo. 52.3 Designing the User Interface The user interface will need to be comprised of three Button views and a single EditText view.
Within the Project tool window, navigate to the activity_storage_demo.xml layout file located in app -> res -> layout and double click on it to load it into the Designer tool. With the tool in Design mode, select and delete the Hello World! TextView object. Switch the Designer tool to Text mode and remove the padding elements from the file so that it now reads as outlined in the following listing: