Effortlessly manage local storage on Android with NexDB.
Official documentation can be on docs - Check some examples below. The example application is provided in the example folder in the source.
- Simple and clean integration process with minimal configuration.
- Automatic table and column naming via reflection.
- Seamless migrations between different schema versions.
Preferred method. Add the following:
implementation 'com.github.krishpranav:nexdb:1.0'
Then run gradle build
or gradle assemble
.
Declare the dependency in Maven:
<dependency>
<groupId>com.github.krishpranav</groupId>
<artifactId>nexdb</artifactId>
<version>1.0</version>
</dependency>
Include the following in your settings.gradle:
include ':app', ':nexdb'
def getLocalProperty(prop) {
Properties properties = new Properties()
properties.load(new File(rootDir.absolutePath + '/local.properties').newDataInputStream())
return properties.getProperty(prop, '')
}
project(':nexdb').projectDir = new File(getLocalProperty('nexdb.dir'))
And in local.properties:
nexdb.dir=/path/to/nexdb/library
Add NexDB to dependencies in build.gradle:
dependencies {
implementation project(':nexdb')
}
public class Student extends NexRecord {
@Unique
String dob;
String name;
String class;
public Book() {}
public Book(String dob, String name, String class) {
this.dob = dob;
this.name = name;
this.class = class;
}
}
Student student = new Student("01 Jan", "Some name", "Some class");
book.save();
Student student = Student.findById(Student.class, 1);
Student student = Student.findById(Book.class, 1);
student.title = "Updated Title";
student.save();
student.delete();
List<Student> students = Arrays.asList(
new Book("", "", ""),
new Book("", "", "")
);
NexRecord.saveInTx(students);