0

I want to show the images i have uploaded in the firebase storage through the console. Is there any way I can get the image urls as a list and store it in the database through android studio. Thank you.

Till now for tried i have tried adding the urls manually to the arraylist and used glide to fetch the image, but i want to store the image urls in the database and fetch from there. The problem is I stored the images manually.

Here is my code.

public class QuotesTab extends Fragment {

    private static final String TAG = "QuotesTab";
    private static final int Num_Col = 2;
    private ArrayList<String> mImages = new ArrayList<>();
    private RecyclerView mrecyclerView;
    View v;

    public QuotesTab() {
    }

    @Nullable
    @Override
    public View onCreateView(@NonNull LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) {
        Log.d(TAG, "onCreateView: Preparing Recycler View");
        v = inflater.inflate(R.layout.fragment_quotes, container, false);
        mrecyclerView = v.findViewById(R.id.recycler_view_quotes);
        MyAdapter adapter = new MyAdapter(getContext(), mImages);
        StaggeredGridLayoutManager staggeredGridLayoutManager = new StaggeredGridLayoutManager(Num_Col, LinearLayoutManager.VERTICAL);
        mrecyclerView.setLayoutManager(staggeredGridLayoutManager);
        mrecyclerView.setAdapter(adapter);
        return v;
    }

    @Override
    public void onCreate(@Nullable Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        Log.d(TAG, "onCreate: initbitmaps");

        mImages.add("https://www.mapsofindia.com/wallpapers/tajmahal/images/taj-mahal-front-view.jpg");
        mImages.add("https://images.pexels.com/photos/2466638/pexels-photo-2466638.jpeg?auto=compress&cs=tinysrgb&dpr=1&w=500");
        mImages.add("https://images.pexels.com/photos/2406658/pexels-photo-2406658.jpeg?auto=compress&cs=tinysrgb&dpr=2&h=650&w=940");
        mImages.add("https://images.pexels.com/photos/2385210/pexels-photo-2385210.jpeg?auto=format%2Ccompress&cs=tinysrgb&dpr=2&h=650&w=940");
        mImages.add("https://images.pexels.com/photos/2462980/pexels-photo-2462980.jpeg?auto=compress&cs=tinysrgb&dpr=2&h=650&w=940");
        mImages.add("https://images.pexels.com/photos/2404365/pexels-photo-2404365.jpeg?auto=compress&cs=tinysrgb&dpr=2&h=650&w=940");
        mImages.add("https://images.pexels.com/photos/2404843/pexels-photo-2404843.jpeg?auto=compress&cs=tinysrgb&dpr=2&h=650&w=940");
        mImages.add("https://images.pexels.com/photos/2417260/pexels-photo-2417260.jpeg?auto=compress&cs=tinysrgb&dpr=2&h=650&w=940");
        mImages.add("https://images.pexels.com/photos/2407636/pexels-photo-2407636.jpeg?auto=compress&cs=tinysrgb&dpr=2&h=650&w=940");
        mImages.add("https://images.pexels.com/photos/2404055/pexels-photo-2404055.jpeg?auto=compress&cs=tinysrgb&dpr=2&h=650&w=940");
        mImages.add("https://images.pexels.com/photos/2405644/pexels-photo-2405644.jpeg?auto=compress&cs=tinysrgb&dpr=2&h=650&w=940");
        mImages.add("https://images.pexels.com/photos/2387418/pexels-photo-2387418.jpeg?auto=compress&cs=tinysrgb&dpr=2&h=650&w=940");
        mImages.add("https://images.pexels.com/photos/2407121/pexels-photo-2407121.jpeg?auto=compress&cs=tinysrgb&dpr=2&h=650&w=940");
        mImages.add("https://images.pexels.com/photos/2403014/pexels-photo-2403014.jpeg?auto=compress&cs=tinysrgb&dpr=1&w=500");
        mImages.add("https://images.pexels.com/photos/2403014/pexels-photo-2403014.jpeg?auto=compress&cs=tinysrgb&dpr=2&h=650&w=940");
        mImages.add("https://images.pexels.com/photos/2376996/pexels-photo-2376996.jpeg?auto=compress&cs=tinysrgb&dpr=2&h=650&w=940");
        mImages.add("https://images.pexels.com/photos/2440493/pexels-photo-2440493.jpeg?auto=compress&cs=tinysrgb&dpr=2&h=650&w=940");
        mImages.add("https://images.pexels.com/photos/2386587/pexels-photo-2386587.jpeg?auto=format%2Ccompress&cs=tinysrgb&dpr=2&h=650&w=940");
        mImages.add("https://images.pexels.com/photos/2404557/pexels-photo-2404557.jpeg?auto=format%2Ccompress&cs=tinysrgb&dpr=2&h=650&w=940");
        mImages.add("https://images.pexels.com/photos/2332413/pexels-photo-2332413.jpeg?auto=compress&cs=tinysrgb&dpr=2&h=650&w=940");

     }
}

I want to store the image url as shown in the image

I want to store image urls in firebase database an fetch it from there.

TylerH
  • 20,799
  • 66
  • 75
  • 101
  • No, please check the duplicate to see how you can get the download url of a picture. – Alex Mamo Jun 22 '19 at 10:54
  • I have uploaded the files through console and i want to get image urls through android studio and the number of images is in thousands. How is this a duplicate question. If you think it is duplicate do send me a link to the solution –  Kevin Jun 24 '19 at 16:16
  • You cannot download an image without having its url. So please check the duplicate in order to see how you can achieve this. Simply uploading through the console won't help you. – Alex Mamo Jun 24 '19 at 16:18
  • Thats what i am asking how to get the download url ? All the answers are related to when we upload an image through the app and then take a snapshot and then get the download url. And My problem is I have uploaded through console so in that case how to get the download url for my 8000+ images through coding in the android studio –  Kevin Jun 24 '19 at 17:22
  • That's why you find all answers that way because you should add your images through the app programmatically and not through the console. – Alex Mamo Jun 24 '19 at 17:29
  • what if have thousands of images and i want to display them in the recycler view how would i use firebase to do that? –  Kevin Jun 27 '19 at 18:45
  • As in the duplicate. – Alex Mamo Jun 28 '19 at 07:32
  • I cant find the duplicate –  Kevin Jun 28 '19 at 16:51
  • At the top of the page. – Alex Mamo Jun 29 '19 at 09:32

1 Answers1

0

you need to use the getDownloadUrl method on the references.

Take a lot at this for more details

andresmijares
  • 3,658
  • 4
  • 34
  • 40
  • I have uploaded the image through the console and also the above method is not really giving me a download url. It would be helpful if you could show me how. And also I have more than 8000 images in the storage. –  Kevin Jun 24 '19 at 09:49