- Stitch >
- MongoDB Mobile >
- Usage Guides
Build a Local-Only Mobile App¶
On this page
Deprecation
MongoDB has deprecated MongoDB Mobile. We are focusing our efforts on Realm, the most popular database for mobile devices.
Overview¶
After setting up your Android or iOS project to use the MongoDB Stitch SDKs, you are ready to initialize MongoDB Stitch and connect to the database. The following procedure shows you how to build an app that only uses MongoDB Mobile for data storage. For an example that uses both Atlas and MongoDB Mobile in an app, see Build a Mobile App with Sync.
Prerequisites¶
If you have not done so yet, refer to the steps in Set up a MongoDB Mobile Project to set up your Android or iOS project to use the MongoDB Stitch SDKs.
Initializing MongoDB Mobile¶
The following code demonstrates initializing and accessing the local MongoDB Mobile database.
- Android (Java) SDK
- iOS (Swift) SDK
Include the necessary packages:
Initialize the MongoDB Mobile database, and then create a MongoDB Mobile client in the application:
You can now access MongoDB Mobile directly. For example, to point to a collection and insert a document, use the following code:
In your project, add the following code to initialize the MongoDB Stitch client and MongoDB Mobile connection:
Your code can now access MongoDB Mobile directly. For example, to point to a collection and insert a document, use the following code: