Firebase : How to search all objects with same value in whole database or nested databaseWhy does EditText retain its Activity's Context in Ice Cream SandwichCan someone show me a simple working implementation of PagerSlidingTabStrip?setText on button from another activity androidSearch on ListView when the class extends ListActivityAdding Social Media Share Logic From Firebase in Androidjava.lang.NullPointerException when invoking onLoadFinished()Search Firestore query don't show data in RecycleViewRemove leading zero in edittext from a custom zero button in androidHow to add child(Product) under a child(Store) in Firebase Database using RecyclerView
Is it possible to build VPN remote access environment without VPN server?
Crossing US border with music files I'm legally allowed to possess
In general, would I need to season a meat when making a sauce?
How to use " shadow " in pstricks?
The art of clickbait captions
Image processing: Removal of two spots in fundus images
pic versus macro in TikZ
Is neural networks training done one-by-one?
Using credit/debit card details vs swiping a card in a payment (credit card) terminal
the meaning of 'carry' in a novel
Where have Brexit voters gone?
Why does this if-statement combining assignment and an equality check return true?
Python program to find the most frequent letter in a text
Did people go back to where they were?
If a person had control of every single cell of their body, would they be able to transform into another creature?
What is quasi-aromaticity?
Who will lead the country until there is a new Tory leader?
Why is this Simple Puzzle impossible to solve?
Are these reasonable traits for someone with autism?
Why does Mjolnir fall down in Age of Ultron but not in Endgame?
How to execute this code on startup?
What is the object moving across the ceiling in this stock footage?
Installed Electric Tankless Water Heater - Internet loss when active
How to interpret "body that leaned stiffly" in H. P. Lovecraft's "Azathoth"?
Firebase : How to search all objects with same value in whole database or nested database
Why does EditText retain its Activity's Context in Ice Cream SandwichCan someone show me a simple working implementation of PagerSlidingTabStrip?setText on button from another activity androidSearch on ListView when the class extends ListActivityAdding Social Media Share Logic From Firebase in Androidjava.lang.NullPointerException when invoking onLoadFinished()Search Firestore query don't show data in RecycleViewRemove leading zero in edittext from a custom zero button in androidHow to add child(Product) under a child(Store) in Firebase Database using RecyclerView
.everyoneloves__top-leaderboard:empty,.everyoneloves__mid-leaderboard:empty,.everyoneloves__bot-mid-leaderboard:empty height:90px;width:728px;box-sizing:border-box;
How to get all objects with the same name_mov
value from the nested database. I have a EditText
from where I get a string for searching for objects with the same mov_name
value from the nested database. I want to show the list of all objects under bolly/new
and also bolly/popular
with same mov_name
value in RecyclerView
with Firebase-UI.
Here is the database structure:
What have I done -
@Override
protected void onCreate(Bundle savedInstanceState)
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_search);
progressBar = findViewById(R.id.spin_search);
progressBar.setVisibility(View.GONE);
recyclerView = findViewById(R.id.rec_search);
recyclerView.setLayoutManager(new LinearLayoutManager(this));
editText = findViewById(R.id.ed_search);
editText.addTextChangedListener(new TextWatcher()
@Override
public void beforeTextChanged(CharSequence s, int start, int count, int after)
@Override
public void onTextChanged(CharSequence s, int start, int before, int count)
firebaseSearch(s.toString());
@Override
public void afterTextChanged(Editable s)
);
mFirebaseDatabase = FirebaseDatabase.getInstance();
mDatabaseReference = mFirebaseDatabase.getReference();
//search data
private void firebaseSearch(String s)
/*Toast.makeText(AllUserActivity.this, "Started Search", Toast.LENGTH_LONG).show();*/
progressBar.setVisibility(View.VISIBLE);
Query firebaseSearchQuery = mDatabaseReference.equalTo(s);
//set Options
FirebaseRecyclerOptions<MovieObj> options =
new FirebaseRecyclerOptions.Builder<MovieObj>()
.setQuery(firebaseSearchQuery, MovieObj.class)
.setLifecycleOwner(this)
.build();
adapter = new FirebaseRecyclerAdapter<MovieObj, SearchMovHolder>(options)
@Override
protected void onBindViewHolder(@NonNull SearchMovHolder holder, int position, @NonNull MovieObj model)
progressBar.setVisibility(View.GONE);
holder.name.setText(model.getName_mov());
holder.rating.setText( model.getRating());
holder.year.setText( model.getYear());
Glide.with(holder.img_back.getContext())
.load(model.getImgback())
.into(holder.img_back);
@NonNull
@Override
public SearchMovHolder onCreateViewHolder(@NonNull ViewGroup parent, int viewType)
View mView = LayoutInflater.from(parent.getContext()).inflate(R.layout.search_mov_item, parent, false);
return new SearchMovHolder(mView);
;
recyclerView.setAdapter(adapter);
java android firebase search firebase-realtime-database
add a comment |
How to get all objects with the same name_mov
value from the nested database. I have a EditText
from where I get a string for searching for objects with the same mov_name
value from the nested database. I want to show the list of all objects under bolly/new
and also bolly/popular
with same mov_name
value in RecyclerView
with Firebase-UI.
Here is the database structure:
What have I done -
@Override
protected void onCreate(Bundle savedInstanceState)
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_search);
progressBar = findViewById(R.id.spin_search);
progressBar.setVisibility(View.GONE);
recyclerView = findViewById(R.id.rec_search);
recyclerView.setLayoutManager(new LinearLayoutManager(this));
editText = findViewById(R.id.ed_search);
editText.addTextChangedListener(new TextWatcher()
@Override
public void beforeTextChanged(CharSequence s, int start, int count, int after)
@Override
public void onTextChanged(CharSequence s, int start, int before, int count)
firebaseSearch(s.toString());
@Override
public void afterTextChanged(Editable s)
);
mFirebaseDatabase = FirebaseDatabase.getInstance();
mDatabaseReference = mFirebaseDatabase.getReference();
//search data
private void firebaseSearch(String s)
/*Toast.makeText(AllUserActivity.this, "Started Search", Toast.LENGTH_LONG).show();*/
progressBar.setVisibility(View.VISIBLE);
Query firebaseSearchQuery = mDatabaseReference.equalTo(s);
//set Options
FirebaseRecyclerOptions<MovieObj> options =
new FirebaseRecyclerOptions.Builder<MovieObj>()
.setQuery(firebaseSearchQuery, MovieObj.class)
.setLifecycleOwner(this)
.build();
adapter = new FirebaseRecyclerAdapter<MovieObj, SearchMovHolder>(options)
@Override
protected void onBindViewHolder(@NonNull SearchMovHolder holder, int position, @NonNull MovieObj model)
progressBar.setVisibility(View.GONE);
holder.name.setText(model.getName_mov());
holder.rating.setText( model.getRating());
holder.year.setText( model.getYear());
Glide.with(holder.img_back.getContext())
.load(model.getImgback())
.into(holder.img_back);
@NonNull
@Override
public SearchMovHolder onCreateViewHolder(@NonNull ViewGroup parent, int viewType)
View mView = LayoutInflater.from(parent.getContext()).inflate(R.layout.search_mov_item, parent, false);
return new SearchMovHolder(mView);
;
recyclerView.setAdapter(adapter);
java android firebase search firebase-realtime-database
add a comment |
How to get all objects with the same name_mov
value from the nested database. I have a EditText
from where I get a string for searching for objects with the same mov_name
value from the nested database. I want to show the list of all objects under bolly/new
and also bolly/popular
with same mov_name
value in RecyclerView
with Firebase-UI.
Here is the database structure:
What have I done -
@Override
protected void onCreate(Bundle savedInstanceState)
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_search);
progressBar = findViewById(R.id.spin_search);
progressBar.setVisibility(View.GONE);
recyclerView = findViewById(R.id.rec_search);
recyclerView.setLayoutManager(new LinearLayoutManager(this));
editText = findViewById(R.id.ed_search);
editText.addTextChangedListener(new TextWatcher()
@Override
public void beforeTextChanged(CharSequence s, int start, int count, int after)
@Override
public void onTextChanged(CharSequence s, int start, int before, int count)
firebaseSearch(s.toString());
@Override
public void afterTextChanged(Editable s)
);
mFirebaseDatabase = FirebaseDatabase.getInstance();
mDatabaseReference = mFirebaseDatabase.getReference();
//search data
private void firebaseSearch(String s)
/*Toast.makeText(AllUserActivity.this, "Started Search", Toast.LENGTH_LONG).show();*/
progressBar.setVisibility(View.VISIBLE);
Query firebaseSearchQuery = mDatabaseReference.equalTo(s);
//set Options
FirebaseRecyclerOptions<MovieObj> options =
new FirebaseRecyclerOptions.Builder<MovieObj>()
.setQuery(firebaseSearchQuery, MovieObj.class)
.setLifecycleOwner(this)
.build();
adapter = new FirebaseRecyclerAdapter<MovieObj, SearchMovHolder>(options)
@Override
protected void onBindViewHolder(@NonNull SearchMovHolder holder, int position, @NonNull MovieObj model)
progressBar.setVisibility(View.GONE);
holder.name.setText(model.getName_mov());
holder.rating.setText( model.getRating());
holder.year.setText( model.getYear());
Glide.with(holder.img_back.getContext())
.load(model.getImgback())
.into(holder.img_back);
@NonNull
@Override
public SearchMovHolder onCreateViewHolder(@NonNull ViewGroup parent, int viewType)
View mView = LayoutInflater.from(parent.getContext()).inflate(R.layout.search_mov_item, parent, false);
return new SearchMovHolder(mView);
;
recyclerView.setAdapter(adapter);
java android firebase search firebase-realtime-database
How to get all objects with the same name_mov
value from the nested database. I have a EditText
from where I get a string for searching for objects with the same mov_name
value from the nested database. I want to show the list of all objects under bolly/new
and also bolly/popular
with same mov_name
value in RecyclerView
with Firebase-UI.
Here is the database structure:
What have I done -
@Override
protected void onCreate(Bundle savedInstanceState)
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_search);
progressBar = findViewById(R.id.spin_search);
progressBar.setVisibility(View.GONE);
recyclerView = findViewById(R.id.rec_search);
recyclerView.setLayoutManager(new LinearLayoutManager(this));
editText = findViewById(R.id.ed_search);
editText.addTextChangedListener(new TextWatcher()
@Override
public void beforeTextChanged(CharSequence s, int start, int count, int after)
@Override
public void onTextChanged(CharSequence s, int start, int before, int count)
firebaseSearch(s.toString());
@Override
public void afterTextChanged(Editable s)
);
mFirebaseDatabase = FirebaseDatabase.getInstance();
mDatabaseReference = mFirebaseDatabase.getReference();
//search data
private void firebaseSearch(String s)
/*Toast.makeText(AllUserActivity.this, "Started Search", Toast.LENGTH_LONG).show();*/
progressBar.setVisibility(View.VISIBLE);
Query firebaseSearchQuery = mDatabaseReference.equalTo(s);
//set Options
FirebaseRecyclerOptions<MovieObj> options =
new FirebaseRecyclerOptions.Builder<MovieObj>()
.setQuery(firebaseSearchQuery, MovieObj.class)
.setLifecycleOwner(this)
.build();
adapter = new FirebaseRecyclerAdapter<MovieObj, SearchMovHolder>(options)
@Override
protected void onBindViewHolder(@NonNull SearchMovHolder holder, int position, @NonNull MovieObj model)
progressBar.setVisibility(View.GONE);
holder.name.setText(model.getName_mov());
holder.rating.setText( model.getRating());
holder.year.setText( model.getYear());
Glide.with(holder.img_back.getContext())
.load(model.getImgback())
.into(holder.img_back);
@NonNull
@Override
public SearchMovHolder onCreateViewHolder(@NonNull ViewGroup parent, int viewType)
View mView = LayoutInflater.from(parent.getContext()).inflate(R.layout.search_mov_item, parent, false);
return new SearchMovHolder(mView);
;
recyclerView.setAdapter(adapter);
java android firebase search firebase-realtime-database
java android firebase search firebase-realtime-database
edited Mar 24 at 8:35
Alex Mamo
49.9k83169
49.9k83169
asked Mar 24 at 5:21
Smarpit SinghSmarpit Singh
259
259
add a comment |
add a comment |
1 Answer
1
active
oldest
votes
There is no way you can achieve this using your database structure since between your root node and the objects that contain the name_mov
property there are 4 childs, mov
, bolly
, new
and the pushed id.
You can use the following query:
Query firebaseSearchQuery = mDatabaseReference
.child("mov")
.child("bolly")
.child("new")
.orderByChild("name_mov")
.equalTo(s);
But you'll only be able to get the movie titles that exist within the new
node. If you want to get all titles you should restructure your database by adding the type of the movie (new, popular and so on) as a property of your objects and then simply use:
Query firebaseSearchQuery = mDatabaseReference
.child("mov")
.child("bolly")
.orderByChild("name_mov")
.equalTo(s);
In this way, you'll a have level less and the query will work perfectly fine.
I can't change my database structure. Should I make multiple firebase queries and combine the response of those queries in a single list for showing in recyclerview? or there is any way to archive it.
– Smarpit Singh
Mar 24 at 11:57
1
Yes, you can also go ahead that way but only if you have 2 or 3 such nodes. If you have more than that, I still recommend you change your database structure.
– Alex Mamo
Mar 24 at 11:59
add a comment |
Your Answer
StackExchange.ifUsing("editor", function ()
StackExchange.using("externalEditor", function ()
StackExchange.using("snippets", function ()
StackExchange.snippets.init();
);
);
, "code-snippets");
StackExchange.ready(function()
var channelOptions =
tags: "".split(" "),
id: "1"
;
initTagRenderer("".split(" "), "".split(" "), channelOptions);
StackExchange.using("externalEditor", function()
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled)
StackExchange.using("snippets", function()
createEditor();
);
else
createEditor();
);
function createEditor()
StackExchange.prepareEditor(
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
imageUploader:
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
,
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
);
);
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f55320958%2ffirebase-how-to-search-all-objects-with-same-value-in-whole-database-or-nested%23new-answer', 'question_page');
);
Post as a guest
Required, but never shown
1 Answer
1
active
oldest
votes
1 Answer
1
active
oldest
votes
active
oldest
votes
active
oldest
votes
There is no way you can achieve this using your database structure since between your root node and the objects that contain the name_mov
property there are 4 childs, mov
, bolly
, new
and the pushed id.
You can use the following query:
Query firebaseSearchQuery = mDatabaseReference
.child("mov")
.child("bolly")
.child("new")
.orderByChild("name_mov")
.equalTo(s);
But you'll only be able to get the movie titles that exist within the new
node. If you want to get all titles you should restructure your database by adding the type of the movie (new, popular and so on) as a property of your objects and then simply use:
Query firebaseSearchQuery = mDatabaseReference
.child("mov")
.child("bolly")
.orderByChild("name_mov")
.equalTo(s);
In this way, you'll a have level less and the query will work perfectly fine.
I can't change my database structure. Should I make multiple firebase queries and combine the response of those queries in a single list for showing in recyclerview? or there is any way to archive it.
– Smarpit Singh
Mar 24 at 11:57
1
Yes, you can also go ahead that way but only if you have 2 or 3 such nodes. If you have more than that, I still recommend you change your database structure.
– Alex Mamo
Mar 24 at 11:59
add a comment |
There is no way you can achieve this using your database structure since between your root node and the objects that contain the name_mov
property there are 4 childs, mov
, bolly
, new
and the pushed id.
You can use the following query:
Query firebaseSearchQuery = mDatabaseReference
.child("mov")
.child("bolly")
.child("new")
.orderByChild("name_mov")
.equalTo(s);
But you'll only be able to get the movie titles that exist within the new
node. If you want to get all titles you should restructure your database by adding the type of the movie (new, popular and so on) as a property of your objects and then simply use:
Query firebaseSearchQuery = mDatabaseReference
.child("mov")
.child("bolly")
.orderByChild("name_mov")
.equalTo(s);
In this way, you'll a have level less and the query will work perfectly fine.
I can't change my database structure. Should I make multiple firebase queries and combine the response of those queries in a single list for showing in recyclerview? or there is any way to archive it.
– Smarpit Singh
Mar 24 at 11:57
1
Yes, you can also go ahead that way but only if you have 2 or 3 such nodes. If you have more than that, I still recommend you change your database structure.
– Alex Mamo
Mar 24 at 11:59
add a comment |
There is no way you can achieve this using your database structure since between your root node and the objects that contain the name_mov
property there are 4 childs, mov
, bolly
, new
and the pushed id.
You can use the following query:
Query firebaseSearchQuery = mDatabaseReference
.child("mov")
.child("bolly")
.child("new")
.orderByChild("name_mov")
.equalTo(s);
But you'll only be able to get the movie titles that exist within the new
node. If you want to get all titles you should restructure your database by adding the type of the movie (new, popular and so on) as a property of your objects and then simply use:
Query firebaseSearchQuery = mDatabaseReference
.child("mov")
.child("bolly")
.orderByChild("name_mov")
.equalTo(s);
In this way, you'll a have level less and the query will work perfectly fine.
There is no way you can achieve this using your database structure since between your root node and the objects that contain the name_mov
property there are 4 childs, mov
, bolly
, new
and the pushed id.
You can use the following query:
Query firebaseSearchQuery = mDatabaseReference
.child("mov")
.child("bolly")
.child("new")
.orderByChild("name_mov")
.equalTo(s);
But you'll only be able to get the movie titles that exist within the new
node. If you want to get all titles you should restructure your database by adding the type of the movie (new, popular and so on) as a property of your objects and then simply use:
Query firebaseSearchQuery = mDatabaseReference
.child("mov")
.child("bolly")
.orderByChild("name_mov")
.equalTo(s);
In this way, you'll a have level less and the query will work perfectly fine.
edited Mar 24 at 12:15
Smarpit Singh
259
259
answered Mar 24 at 8:34
Alex MamoAlex Mamo
49.9k83169
49.9k83169
I can't change my database structure. Should I make multiple firebase queries and combine the response of those queries in a single list for showing in recyclerview? or there is any way to archive it.
– Smarpit Singh
Mar 24 at 11:57
1
Yes, you can also go ahead that way but only if you have 2 or 3 such nodes. If you have more than that, I still recommend you change your database structure.
– Alex Mamo
Mar 24 at 11:59
add a comment |
I can't change my database structure. Should I make multiple firebase queries and combine the response of those queries in a single list for showing in recyclerview? or there is any way to archive it.
– Smarpit Singh
Mar 24 at 11:57
1
Yes, you can also go ahead that way but only if you have 2 or 3 such nodes. If you have more than that, I still recommend you change your database structure.
– Alex Mamo
Mar 24 at 11:59
I can't change my database structure. Should I make multiple firebase queries and combine the response of those queries in a single list for showing in recyclerview? or there is any way to archive it.
– Smarpit Singh
Mar 24 at 11:57
I can't change my database structure. Should I make multiple firebase queries and combine the response of those queries in a single list for showing in recyclerview? or there is any way to archive it.
– Smarpit Singh
Mar 24 at 11:57
1
1
Yes, you can also go ahead that way but only if you have 2 or 3 such nodes. If you have more than that, I still recommend you change your database structure.
– Alex Mamo
Mar 24 at 11:59
Yes, you can also go ahead that way but only if you have 2 or 3 such nodes. If you have more than that, I still recommend you change your database structure.
– Alex Mamo
Mar 24 at 11:59
add a comment |
Thanks for contributing an answer to Stack Overflow!
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f55320958%2ffirebase-how-to-search-all-objects-with-same-value-in-whole-database-or-nested%23new-answer', 'question_page');
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown