Posted on Leave a comment

Content provider

Content providers are one of the primary building blocks of Android applications, providing content to applications. They encapsulate data and provide it to applications through the single ContentResolver interface. A content provider is only required if you need to share data between multiple applications. For example, the contacts data is used by multiple applications and must be stored in a content provider. If you don’t need to share data amongst multiple applications you can use a database directly via SQLiteDatabase.

When a request is made via a ContentResolver the system inspects the authority of the given URI and passes the request to the content provider registered with the authority. The content provider can interpret the rest of the URI however it wants. The UriMatcher class is helpful for parsing URIs.

Continue reading Content provider

Posted on Leave a comment

POJO, equals, hashcode

How to simplify developing of pojo classes?

Problems:

  • pojo class is simple class with members, getters, setters. To keep test coverage more  80% we should develop tests for pojo classes. But it is a ridiculous.
  • do not forget to add new members to equals and hashcode methods.

Decisions:

  • Lombok. We have to type just members of class and use annotations. But there are problems:
    • final members without initialization
    • there are conflicts in annotationProcessor
  • AutoValue. by Google.
    • complicated to use
    • generate child class
  • Kotlin data classes.
    • by Google
    • no problems in annotationProcessor
    • we use Kotlin!!!