Simple Implementation Firebase Storage in Android Studio Projects

in #utopian-io6 years ago (edited)

firebasestorage.png

In this project I used a relatively simple example to implement one of the features on a firebase platform that is firebase storage,
I want to show the beginners and newcomers and also the experienced mobile application developers,
how powerful and easy it is to use the cloud storage feature of firebase.

I also want to motivate people to handle the governance techniques
how to use cloud platform which is the solution of future development.

HOW TO USE THIS PROJECT

1.Clone or Download This Repository
Screen Shot 2017-12-13 at 9.41.10 AM.png

2.As always the first step is open the Android Studio and Open Existing Project then select the project you have downloaded or clone earlier.

3.When your project is loaded, you can add Firebase storage to it.

  • To add Firebase Storage, click on Tools -> Firebase
  • Screen Shot 2017-12-13 at 9.49.51 AM.png

  • An assistant window would open in left with all the firebase features. We have to select Firebase Storage from the list.
  • Screen Shot 2017-12-13 at 9.51.51 AM.png

  • Now you will see a link saying Upload and Download a File with Firebase Storage click on it.
  • Screen Shot 2017-12-13 at 9.53.50 AM.png

  • Click on Connect to Firebase. You will see a dialog asking to create a new firebase app or choose an existing one.
  • Now Click on the second button Add Firebase Storage to Your App.
  • Then click on accept changes and firebase storage is added.
  • 4.Upload Layout
    You can see the upload layout here.
    Screen Shot 2017-12-13 at 10.00.24 AM.png

    We have the following components in the above layout code.

  • Choose Button: We will tap this button to choose an image from the gallery.
  • EditText Enter Name: In this EditText we will put the label for the chosen image.
  • ImageView: The middle area (you cann’t see it in the layout because it is blank ImageView) contains an ImageView where we will display the chosen image.
  • Upload Button: Tapping this button will upload the selected image to Firebase Storage.
  • TextView Uploads: Tapping this TextView will open another activity where we will display the uploaded images with labels.
  • This is the activity_main.xml code
    Screen Shot 2017-12-13 at 10.18.22 AM.png
    Screen Shot 2017-12-13 at 10.18.43 AM.png

    preview of the layout above

    Screen Shot 2017-12-13 at 10.20.06 AM.png

    5.The Upload Process Code
    in the main folder I have create three main code for doing the upload process

    Screen Shot 2017-12-13 at 10.25.39 AM.png

    Constants.java

    This Class developed for Defining Firebase Constants

    Screen Shot 2017-12-13 at 10.30.06 AM.png

    MainAcvtivity.java

    Defining View Objects and Constants
    Screen Shot 2017-12-13 at 10.32.28 AM.png

    initialize the the objects and attach click listeners in OnCreate method

    Screen Shot 2017-12-13 at 10.34.45 AM.png

    File Chooser Method

    Screen Shot 2017-12-13 at 10.35.49 AM.png

    Handle the Intent result by overriding onActivityResult method

    Screen Shot 2017-12-13 at 10.37.07 AM.png

    overriden method onClick() for calling showFileChooser() method

    Screen Shot 2017-12-13 at 10.39.40 AM.png

    Getting Selected File Extension

    Screen Shot 2017-12-13 at 10.43.27 AM.png

    Uploading the File to Firebase Storage

    Screen Shot 2017-12-13 at 10.45.50 AM.png
    Screen Shot 2017-12-13 at 10.45.58 AM.png

    Upload.java

    This Class developed for Building Database Model for uploaded image

    Screen Shot 2017-12-13 at 10.42.04 AM.png

    By learning this repository I hope, with beginner development experience only.
    the developers can use a reliable, simple, and cost-effective storage object created for the Google scale.
    For android applications that they are developing.

    Screen Shot 2017-12-12 at 10.07.24 PM.png
    [Additional proof of work]

    Links:
    https://github.com/iqbal09/AndroidFirebaseStorageExample

    Documentation About Firebase Storage for android:
    https://firebase.google.com/docs/storage/android/upload-files?hl=en.



    Posted on Utopian.io - Rewarding Open Source Contributors

    Sort:  

    Hi @tenorbalonzo, Thanks for your perfect support :)

    Your contribution cannot be approved yet because it is not as informative as other contributions. Could you please provide more details about the relevant parts of the code? Maybe also include code examples.

    I want to show the beginners and newcomers [...]

    You said it yourself but there's no further info except the code itself. A few instructional words would be great! :)

    You may edit your post here, as shown below:

    You can contact us on Discord.
    [utopian-moderator]

    Hi , @mkt I Have modified the post as your suggestion , Please review it again :)

    Thank you!. It has been approved now.

    You can contact us on Discord.
    [utopian-moderator]

    Hey @iqbalhood I am @utopian-io. I have just upvoted you!

    Achievements

    • You have less than 500 followers. Just gave you a gift to help you succeed!
    • Seems like you contribute quite often. AMAZING!

    Community-Driven Witness!

    I am the first and only Steem Community-Driven Witness. Participate on Discord. Lets GROW TOGETHER!

    mooncryption-utopian-witness-gif

    Up-vote this comment to grow my power and help Open Source contributions like this one. Want to chat? Join me on Discord https://discord.gg/Pc8HG9x

    Thank you very much for your post. It would be helpful to understand if you could add a short description of the app you were creating at the beginning of your post.

    It took some time for me to figure out what you were creating until I read more near the middle.

    Also is there any chance you can post a quick video of the whole process?

    Off course , I Will Post The Video , Coming Soon This Week :)

    Coin Marketplace

    STEEM 0.28
    TRX 0.12
    JST 0.033
    BTC 61641.91
    ETH 2997.57
    USDT 1.00
    SBD 3.45