The News App is a modern Android news reader application built using Kotlin and the MVVM architectural pattern.
It allows users to browse top headlines, search for news articles, read full articles inside the app, and save favourite articles locally for later access.
The application integrates live news data from NewsAPI, supports local persistence using Room Database, and provides a clean multi-screen user experience using Navigation Components, RecyclerView, and ViewBinding.
The News App is designed to provide a simple and efficient mobile news experience.
Users can:
- View top news headlines
- Search for articles by keyword
- Open and read full articles inside the app
- Save articles to favourites
- Remove articles from favourites
- Browse news through a clean bottom-navigation-based interface
The application combines online API data fetching with offline local storage for saved news articles.
The app fetches and displays the latest top headlines from the NewsAPI service.
Features include:
- Country-based headline loading
- Paginated news loading
- Infinite scrolling
- Loading indicators
- Error handling with retry support
Users can search for specific news topics or keywords.
Search features include:
- Query-based news search
- Paginated search results
- Loading states
- Search delay support for smoother requests
- Error handling with retry support
Users can open any news item and read the full content inside the application.
Features include:
- In-app article viewing using WebView
- JavaScript and DOM storage enabled for better page rendering
- Safe handling of missing article data or invalid URLs
Users can save articles locally for future access.
Features include:
- Save article to favourites
- View all saved articles in a dedicated screen
- Remove articles using swipe gestures
- Undo delete with Snackbar
- Offline access to favourite news articles
- Kotlin
- Fragments
- RecyclerView
- ViewBinding
- Navigation Component
- Safe Args
- WebView
- Snackbar
- BottomNavigationView
- MVVM (Model-View-ViewModel)
- Repository pattern
- Retrofit
- Gson Converter
- OkHttp Logging Interceptor
- Room Database
- DAO
- Type Converters
- Glide
- Kotlin Coroutines
- LiveData
- ViewModel
NewsAPI
|
v
Retrofit + Repository
|
v
ViewModel + LiveData
|
v
Fragments / RecyclerView UI
|
v
Room Database (Favourites)
The app follows an MVVM-based data flow where:
- API layer fetches remote news data
- Repository coordinates remote and local data access
- ViewModel manages UI state
- Fragments render the data
- Room stores favourite articles locally
TheNewsApp
│
├── app
│ ├── src/main/java/com/example/thenewsapp
│ │ ├── adapters
│ │ │ └── NewsAdapter.kt
│ │ │
│ │ ├── api
│ │ │ ├── NewsAPI.kt
│ │ │ └── RetrofitInstance.kt
│ │ │
│ │ ├── db
│ │ │ ├── ArticleDAO.kt
│ │ │ ├── ArticleDatabase.kt
│ │ │ └── Converters.kt
│ │ │
│ │ ├── models
│ │ │ ├── Article.kt
│ │ │ ├── NewsResponse.kt
│ │ │ └── Source.kt
│ │ │
│ │ ├── repository
│ │ │ └── NewsRepository.kt
│ │ │
│ │ ├── ui
│ │ │ ├── NewsActivity.kt
│ │ │ ├── NewsViewModel.kt
│ │ │ ├── NewsViewModelProviderFactory.kt
│ │ │ └── fragments
│ │ │ ├── ArticleFragment.kt
│ │ │ ├── FavouritesFragment.kt
│ │ │ ├── HeadlinesFragment.kt
│ │ │ └── SearchFragment.kt
│ │ │
│ │ └── util
│ │ ├── Constants.kt
│ │ └── Resource.kt
│ │
│ ├── src/main/res
│ │ ├── layout
│ │ ├── navigation
│ │ ├── menu
│ │ ├── drawable
│ │ ├── values
│ │ └── xml
│ │
│ └── AndroidManifest.xml
│
├── gradle
├── build.gradle.kts
├── settings.gradle.kts
├── gradle.properties
├── gradlew
├── gradlew.bat
└── README.md
Displays trending top headlines using a RecyclerView.
Allows users to search for news articles by keyword.
Opens the selected article in a WebView.
Displays articles saved locally in the Room database.
The project follows the Model-View-ViewModel architecture.
Represents the data layer:
ArticleNewsResponseSource
Represents the UI layer:
- Fragments
- RecyclerView layouts
- Activity
- WebView
Acts as the bridge between UI and data:
NewsViewModel
This improves maintainability, readability, and separation of concerns.
Favourite articles are stored locally using Room.
Database-related components:
ArticleDAO.ktArticleDatabase.ktConverters.kt
Stored operations include:
- Insert / update article
- Retrieve all favourite articles
- Delete article
This allows offline access to saved news.
The app uses NewsAPI to fetch live news content.
Implemented endpoints include:
top-headlineseverything
Networking is handled using:
- Retrofit
- Gson converter
- OkHttp logging interceptor
- Android Studio
- Android SDK
- Kotlin support
- Internet connection for live news fetching
- A valid NewsAPI key
- Clone the repository:
git clone https://github.com/yourusername/TheNewsApp.git-
Open the project in Android Studio
-
Let Gradle sync complete
-
Run the app on:
- Android Emulator
- Physical Android device
This project uses NewsAPI for fetching live news.
The API key is referenced in:
Constants.ktExample:
const val API_KEY = "YOUR_NEWS_API_KEY"For security, it is recommended not to commit real API keys to a public repository.
Replace the API key with your own key from NewsAPI before running the project.
The app supports paginated loading of results for both headlines and search.
The project uses a Resource wrapper to handle:
- Success
- Error
- Loading
This improves UI state management.
Users can:
- Save an article to favourites
- Remove it with swipe
- Restore it using Undo
The project uses Navigation Safe Args to safely pass selected article data between fragments.
The UI includes:
- Bottom navigation menu
- Card-based news item design
- Search field with custom styling
- Progress bars for loading states
- Error cards with retry support
- Custom font integration
Main libraries used in this project include:
- AndroidX Core
- AppCompat
- Material Design
- ConstraintLayout
- Lifecycle ViewModel
- Room
- Retrofit
- Gson Converter
- OkHttp Logging Interceptor
- Navigation Components
- Glide
- Kotlin Coroutines
Possible future enhancements include:
- Category-based filtering
- Dark mode improvements
- Bookmark syncing with cloud
- Offline caching of headlines
- Better search suggestions
- Share article feature
- Push notifications for breaking news
- API key management through local properties or BuildConfig
The News App is a functional Android news reader application that demonstrates:
- Kotlin Android development
- MVVM architecture
- REST API integration
- Room database usage
- Fragment navigation
- RecyclerView implementation
- WebView article reading
- Local favourites persistence
It can be extended into a production-ready mobile news platform with additional personalization and caching features.
Chanuth Jayasekera