Select chapter



basics (6.papers)
activities (5.papers)
services (2.papers)
threads (2.papers)
receivers (1.papers)
advanced android (2.papers)
SQLite database (1.papers)
adapters (1.papers)
adb and ddms (1.papers)
widgets (1.papers)
fragments (1.papers)
UI (1.papers)
Hide

Sponsored Links


  

android interview questions and answers

1
For querying content provider which one to use, getWritabledatabase or getReadabledatabase?
  1. can use either
  2. use getReadableDatabase
  3. preferred to use getWritableDatabase
  4. both are not required.
Show Answer
Share Facebook gmail Twitter
2
When does onCreate() function of ContentProvider will be called?
  1. First time when any client calls that content provider.
  2. First time when the application containing that content provider is loaded into the memory, it will be called.
  3. After phone boots up Android will call onCreate() of all content providers in the phone.
  4. onCreate() will be called every time if some client calls any DML functions on this content provider.
Show Answer
Share Facebook gmail Twitter
3
What is the purpose of the ContentProvider class?
  1. To play rich media content files.
  2. To share data between Android applications.
  3. To access the global information about an application environment.
  4. To maintain global application state.
Show Answer
Share Facebook gmail Twitter
4
If you want to share the data across the all applications,you should go for ?
  1. Content Provider
  2. Internal Storage
  3. SQLite Database
  4. Shared Preferences
Show Answer
Share Facebook gmail Twitter
5
What is cursor.moveToNext()?
  1. It will move the cursor to point to next row if it is available, else it returns false.
  2. It will move the cursor to point to next row if it is available, else it crashes.
  3. It will move the cursor to point to next column if it is available, else it returns false.
  4. It will move the cursor to point to next column if it is available, else it crashes.
Show Answer
Share Facebook gmail Twitter
6
After fetching cursor from database query, what will happen if I use cursor.moveToNext() immediately?
  1. yes we can
  2. First we have to check if cursor is valid or not, by comparing with null.
  3. No, we have to pass cursor to cursorfactory first, then only we can move to next row.
  4. none of the above
Show Answer
Share Facebook gmail Twitter
7
What will happen if database is not closed properly after using it?
  1. System will automatically close database, as java has garbage collector.
  2. nothing will happen
  3. It will leak the memory. Once you are done with database we have to close it, because it will be cached into memory when we open it and eat up memory space.
  4. If database is not closed properly, then what ever the data that was inserted & what ever the modifications done in that session will be lost.
Show Answer
Share Facebook gmail Twitter
8
Is it possible to call getWritableDataBase() from onCreate() of ContentProvider?
  1. Yes, we can call.
  2. Yes, we can call but before calling we have to make sure that it is called on different worker thread.
  3. getWritableDataBase() will be called automatically by system. we don't need to call explicitly.
  4. getWritableDatabase() may take lot of time to create and update tables, so its better to differ this call to later point of time. because if we put here, then application loading time will be increased and may irritate user.
Show Answer
Share Facebook gmail Twitter
9
what are the mandatory functions to be implemented for a Content provider?
  1. onCreate, insert, update, delete, query, getType.
  2. onCreate() and getType
  3. only insert, update, delete, and query.
  4. none of the above
Show Answer
Share Facebook gmail Twitter
10
What is android:authorities in content provider?
  1. There is no significance for this authorities. But we have to make sure every content provider should have at least one authority.
  2. To register every content provider with Android, it has to use authorities, other than this there is no significance of it.
  3. This is main key or hint to Android on which content provider the query has to be redirected to. When clients pass URI, it will have authorities in it which should match with authorities part of provider tag.
  4. none of the above
Show Answer
Share Facebook gmail Twitter
Show Answer
Share Facebook gmail Twitter
Show Answer
Share Facebook gmail Twitter
Show Answer
Share Facebook gmail Twitter
Show Answer
Share Facebook gmail Twitter
Show Answer
Share Facebook gmail Twitter
16
Where does the context is available in a Content Provider?
  1. it is available in constructor of the content provider.
  2. it will be available only from onCreate() of content provider.
  3. content providers doesn't have contexts.
  4. none are true.
Show Answer
Share Facebook gmail Twitter
17
How to access context in content provider?
  1. use getContext() in onCreate().
  2. use getApplicationContext() any where.
  3. Context will not have both its own and applications context, it has to depend on others context.
  4. both option 1 and 2 are right.
Show Answer
Share Facebook gmail Twitter
18
Android fetching contact details into application:
What does below code do?

Cursor c1 = this.getContentResolver().query(
                        ContactsContract.Contacts.CONTENT_URI, null, null, null, null);
if(c1 != null && c1.getCount() > 0)
{
  c1.moveToNext();
  String n = c1.getString(c1.getColumnIndex(Contacts.DISPLAY_NAME));
  ...
}
  1. It is getting all rows of contacts table, and fetching all the names.
  2. It is getting all rows of contacts table, and fetching contact name from first row.
  3. It is getting all rows of contacts table, and fetching contact name from last row.
  4. It is getting all rows of contacts table, and fetching contact number from first row.
Show Answer
Share Facebook gmail Twitter
Read more papers :