Giter Site home page Giter Site logo

florent37 / android-nosql Goto Github PK

View Code? Open in Web Editor NEW
287.0 12.0 40.0 173 KB

Lightweight, simple structured NoSQL database for Android

License: Apache License 2.0

Java 99.88% Shell 0.12%
android nosql sql data local saver shared preferences path uri simple cassandra firebase mongo db mongodb hadoop cassandra-database elastic

android-nosql's Introduction

Android-NoSql

Lightweight, simple structured NoSQL database for Android

Android app on Google Play

Download

Buy Me a Coffee at ko-fi.com

Download

dependencies {
    implementation 'com.github.florent37:android-nosql:1.0.0'
}

Save your datas as a structured tree

noSql.put("/users/", "florent")
noSql.put("/users/", "kevin")
nosql.put("/identifiers/florent", 10)
nosql.put("/identifiers/kevin", 12)

The data structure will be

/
---users/
      ---"florent"
      ---"kevin"
---identifiers/
      ---florent/
             ---10
      ---kevin/
             ---12

It'll be simple to search data

int myId = noSql.get("/identifiers/florent/").integer();

Serialize objects

You can simply add nodes from POJOS

final User user = new User(
                "flo",
                new House("paris"),
                Arrays.asList(new Car("chevrolet camaro"), new Car("ford gt"))
        );

noSql.put("/user/florent/", user);
/
 ---users/
       ---florent/
               ---name/
                    ---"flo"
               ---house/
                    ---adress/
                           ---"paris"
               ---cars/
                    ---0/
                      ---model/
                            ---"chevrolet camaro"
                    ---1/
                      ---model/
                            ---"ford gt"

Get Objects from node

Or fetch nodes directly into Java Objects

User user = noSql.get("/user/florent/", User.class);

Navigate

noSql.node("/identifiers/")
     .child("florent")
     .childNodes()
     .get(1)
     .put("country", "france");

Listeners

You can listen for nodes updates

noSql.notify("/user/", new Listener() {
            @Override
            public void nodeChanged(String path, NoSql.Value value) {
                //notified when :
                // - the node is created
                // - the node is deleted
                // - a subnode is added / updated
             }
        });

Init

Android-NoSql need to be initialized to store your objects

public class MainApplication extends Application {

    @Override
    public void onCreate() {
        super.onCreate();

        AndroidNoSql.initWithDefault(context);
    }
}

You can also define the datasavers using initWith, it means you can store your data into SqlDatabase, or any storage library your want ;)

Credits

Author: Florent Champigny

Blog : http://www.tutos-android-france.com/

Fiches Plateau Moto : https://www.fiches-plateau-moto.fr/

Android app on Google Play Follow me on Google+ Follow me on Twitter Follow me on LinkedIn

License

Copyright 2017 Florent37, Inc.

Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at

   http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.

android-nosql's People

Contributors

elexl avatar florent37 avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

android-nosql's Issues

Jacoco causes a crash

First of all a huge thanks for your library!

I was trying to use it and ran into a rather strange bug. The put operation always threw a exception:

java.lang.ClassCastException: boolean[] cannot be cast to java.lang.Object[]
at com.github.florent37.androidnosql.NoSql$Node.write(NoSql.java:475)

Further digging with the LogDataServer revealed this:

nodes: /user/florent/cars/0/$jacocoData/ -> []

For some very strange reason the db tries to save coverage data associated with the jacoco plugin.

I could also replicate it in your example app when I added:

apply plugin: 'jacoco'

android {
buildTypes {
debug {
testCoverageEnabled = true
}
}
}

in the build.gradle file of the app module.

I hope this helps while debugging the issue!

A few questions

Hi @florent37 ,

A few questions about this repo below;

  1. Where is the database saved, in relation to file storage.
  2. How to loop through do we use noSql.get("/users/", User.class);

issue

how delete and update.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.