Search

androidtour

Month

December 2015

Best site to learn JSON | GSON | JACKSON [link]

http://www.technotalkative.com

http://www.journaldev.com/2321/google-gson-api-for-json-processing-example-tutorial

http://www.journaldev.com/2324/jackson-json-processing-api-in-java-example-tutorial

http://www.javacodegeeks.com/2011/01/android-json-parsing-gson-tutorial.html

http://www.jsonschema2pojo.org/

Advertisements

MongoDB Practical using JAVA

Before start this Practical you should perform some task.

  1. Visit this and perform this practical on your machine.
  2. Download mongoDB-java-driver.jar
  3. Download / Clone my github practical list.
  4. Open in Netbeans.

MongoDB Basic Command with Screenshot

ice_screenshot_20151226-203545

 

Command for Show Collection

ice_screenshot_20151226-203918ice_screenshot_20151226-203600

javaFX Material Design Tutorial

https://www.youtube.com/channel/UCN1uaBxYSaVqDZMeSwOj_Xw/videos

 

[MongoDB Tutorial] Using Map Reduce to Manipulate Results of Request from the shell.

Download Example

To understand map reduce operation on a collection to generate specific results.

ice_screenshot_20151228-201639

 

[MongoDB Tutorial] Generating Aggregated Data from a Collection.

Download Example

To understand aggregate operations to retrieve aggregated data sets from a collection.

 

[MongoDB Tutorial] Grouping Objects by Key Values.

Download Example

To understand grouping document together by field values.

ice_screenshot_20151228-185841

[MongoDB Example] Extra Example

Download Example(make_word)

ice_screenshot_20151228-184239

Download Example(doc_add_error)

ice_screenshot_20151228-184214

[MongoDB Tutorial] Deleting Documents from a Collection.

Download Example

To understand hoe to delete single and multiple document from collection.

ice_screenshot_20151228-183613

 

[MongoDB Tutorial] Upserting Documents in a Collection.

Download Example

In this example we will see how upsert (insert+update) is work.

ice_screenshot_20151228-183250

[MongoDB Tutorial] Saving Documents in a Collection.

Download Example

To understand saving new and existing documents.

We save new document in existing category name is “blue” and second is create new document.

ice_screenshot_20151228-181802

[MongoDB Tutorial] Updating Documents in a Collection

Download Example

To understand how updating single document as well as group of documents that match a query.

ice_screenshot_20151228-180732

[MongoDB Tutorial] Inserting Documents into a existing Collection.

Download Example

Inserting single document as well as array of document.

For Remove
//wordsColl.remove({word: {$in: [‘tweet’,’google’, ‘selfie’]}});

ice_screenshot_20151228-022950

[MongoDB Tutorial] Retrieving Distinct Values for a Specific Field.

Download Example

To understand ways to generate lists of distinct field values in collections.

We can categories distinct document based on our condition.

ice_screenshot_20151228-020237

 

[MongoDB Tutorial] Paging Through Documents in a Collection.

Download Example

To understand paging through a series of documents in a large data set.

here as per our data total 10 page are there.

ice_screenshot_20151228-015830

 

[MongoDB Tutorial] Limiting Which Document Fields Are Returned from record

Download Example

To Understand which fields are returned in documents using find operations.

ice_screenshot_20151228-015029

 

[MongoDB Tutorial] Limiting Documents Represented by a Cursor.

Download Example

Example to Demonstrate limiting the number of documents returned from find operation.

ice_screenshot_20151228-013242

[MongoDB Tutorial] Sorting Documents Represented by a Cursor.

Download Example

In this Example we sort the Document based on Requirement.

ice_screenshot_20151228-010359

[MongoDB Tutorial] Counting Document Represented by Cursor

Download Example

This Example finds the Number of Document which is store in Cursor.

Using this Method : cursorName.count()

ice_screenshot_20151226-210120

[MongoDB Tutorial] Retrieving Specific Document

Download Example

ice_screenshot_20151226-204704

 

[MongoDB Tutorial] Retrieving Multiple Document

Download Example

In this Example there are total four method to retrieve Document.

1. Using Each List

2. Using Mapped Array

3. Using Indexed Document in Array

4. Using Next Document from Cursor

ice_screenshot_20151226-204234

MongoDB Tutorial [ Finding one Document ]

File Name :find_one.js

mongo = new Mongo(“localhost”);
wordsDB = mongo.getDB(“words”);
wordsColl = wordsDB.getCollection(“word_stats”);
word = wordsColl.findOne();
print(“Single Document: “);
printjson(word);

ice_screenshot_20151226-202837

MongoDB Tutorial [ Creating the Example ]

Download Example

After this Post All Practical is Regarding this Example.

ice_screenshot_20151226-111751

Count the Words from Database

ice_screenshot_20151226-201532

 

Merge two or more activity using merge and include

Download Example(Merge)

Download Example(Include)

Download Example(Include Example 2)

http://developer.android.com/training/improving-layouts/reusing-layouts.html

How to change action bar in android

Download Example

http://www.androidhive.info/2013/11/android-working-with-action-bar/

https://www.youtube.com/watch?v=fx176TdGZC4

http://www.javacodegeeks.com/2014/08/how-to-customize-change-actionbar-font-text-color-icon-layout-and-so-on-with-android.html

http://blog.alwold.com/2013/08/28/styling-tabs-in-the-android-action-bar/

https://blog.stylingandroid.com/styling-the-actionbar-part-1/

http://android-developers.blogspot.in/2011/04/customizing-action-bar.html

 

 

Repeat image in android activity

res/style.xml

<style name="AppTheme" parent="android:Theme.Light" >
    <item name="android:windowBackground">@drawable/app_bg_pattern</item>
</style>

In activity
<bitmap xmlns:android="http://schemas.android.com/apk/res/android"
    android:src="@drawable/back_image" 
    android:tileMode="repeat" />

https://maxalley.wordpress.com/category/android/

Tab at Bottom in android activity

http://madhusudhanrc.blogspot.in/2013/08/bottom-tabbar-control.html

http://blog.lardev.com/2011/02/02/how-to-move-android-tabs-from-top-to-bottom/

http://androidcodeblogspot.blogspot.in/2014/02/android-fragment-tab-example-bottom.html

 

 

 

 

http://www.appsrox.com/android/tutorials/smartpad/2/

 

Change Tab at Top

https://guides.codepath.com/android/ActionBar-Tabs-with-Fragments

Translate SQL query to MongoDB syntax

http://www.querymongo.com/

MongoDB Tutorial [ Delete Collection ]

Purpose : To delete the Collection.

collection_delete.js

mongo=new Mongo(“localhost”);
myDB=mongo.getDB(“newDB”);
collections=myDB.getCollectionNames();
print(“Initial Collections: “);
printjson(collections);

collection=myDB.getCollection(“newCollectionA”);
collection.drop();
print(“After Deleting newCollectionA : “);
collections=myDB.getCollectionNames();
printjson(collections);

collection=myDB.getCollection(“newCollectionB”);
collection.drop();
print(“After Deleting newCollectionB : “);
collections=myDB.getCollectionNames();
printjson(collections);

ice_screenshot_20151210-142542

 

 

MongoDB Tutorial [ show database states ]

Purpose : To show how to display the statistics for a particular database.

db_stats.js

mongo=new Mongo(“localhost”);
myDB=mongo.getDB(“admin”);
stats=myDB.stats();
printjson(stats);

ice_screenshot_20151210-141342

MongoDB Tutorial [ Create new Collections ]

Purpose : How to create new Collection.

collection_create.js

mongo=new Mongo(“localhost”);
newDB=mongo.getDB(“newDB”);
collections=newDB.getCollectionNames();
print(“Initial Collections: “);
printjson(collections);
newDB.createCollection(“newCollectionA”);
newDB.createCollection(“newCollectionB”);
print(“After Collection Creation:”);
collections=newDB.getCollectionNames();
printjson(collections);

ice_screenshot_20151210-141926

MongoDB Tutorial [ Delete Database ]

Purpose : To delete the database.

Step 1: Create file with name db_delete.js

mongo=new Mongo(“localhost”);
myDB=mongo.getDB(“newDB”);
myDB.dropDatabase();

ice_screenshot_20151210-141025

MongoDB Tutorial [ Create new Database]

Purpose : how to create database and verify that it is created using shell.

Step 1:

Create file with name : db_create.js

mongo=new Mongo(“localhost”);
newDB=mongo.getDB(“newDB”);
newDB.createCollection(“newCollection”);

ice_screenshot_20151210-140530

 

MongoDB Tutorial [ Access Control on MongoDB]

Purpose: To show you how to create User and Database Administrator accounts and enable authentication on your MOngoDB server.

For create Administrator account

Step:1 Create file name :add_admin_account.js

mongo=new Mongo(“localhost”);
db=mongo.getDB(“admin”);
db.addUser({
            user:”dbadmin”,
            pwd:”test”,
            roles:[“readWriteAnyDatabase”,
                    “dbAdminAnyDatabase”,
                    “clusterAdmin”]
            });
db.addUser({
            user:”useradmin”,
            pwd:”test”,
            roles:[“userAdminAnyDatabase”]
        })

ice_screenshot_20151210-123033

/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////

Now allow only authenticate user,

ice_screenshot_20151210-125623

Create file with name : mongod_config_auth.txt

verbose=true
port=27017
dbpath=I:\mongo\
auth=true

ice_screenshot_20151210-134501

After config the file write below command in shell

ice_screenshot_20151210-134656

It will show error msg which indicate you have not permission to access user detail.

Now we add authentication using username and password using

db.auth(“<username>”,”<password>”)

ice_screenshot_20151210-134849

 

 

 

MongoDB Tutorial [ Drop user ]

 

ice_screenshot_20151210-105357

Method 2:

Create remove_user.js

mongo = new Mongo(“localhost”);
db=mongo.getDB(“test”);
db.dropUser(“testWriter”)
cur=db.system.users.find();
printjson(cur.toArray());

MongoDB Tutorial [ List all user name with detail ]

Method 1 :Using javascript file

Step 1:

Write this code in list_user.js

mongo = new Mongo(“localhost”);
db=mongo.getDB(“test”);
cur=db.system.users.find();
printjson(cur.toArray());

Write Command in console:

mongo list_user.js

 

Method  2: Using Shell script command

ice_screenshot_20151210-103410

MongoDB Tutorial [ Create user using Shell ]

Step 1:

Write this code in add_user.js file

mongo = new Mongo(“localhost”);
db = mongo.getDB(“test”)
db.addUser({
            user : “tsetAdmin” ,
            pwd : “test” ,
            roles : [“dbadmin”]
            });

db.addUser({
            user : “tsetWriter” ,
            pwd : “test” ,
            roles : [“readWrite”]
            });

db.addUser({
            user : “tsetReader” ,
            pwd : “test” ,
            roles : [“read”]
            });

db = mongo.getDB(“admin”)
db.addUser({
            user : “tsetUser”,
            userSource:”test”,
            roles:[“read”],
            otherDBRoles:{test:[“readWrite”]}
            });

Step 2:

Create running environment of mongodb. [Previous Tutorial]

Step 3:

 

ice_screenshot_20151210-102215

MongoDB tutorial [Practical 1]

Step 1:

set path using command [Tutorial 1]

Step 2:

write in shell : mongo.exe in path of bin folder

for use specific user databse write use <username>

Make one javascript file : shell_script.js

print(“Host Name”);
print(“\t”+hostname());
print(“Date”);
print(“\t”+Date());
db=connect(“localhost/admin”);
print(“Amdin Collections: “);
printjson(db.getCollectionNames());

Save in DBpath directory

Practical 1 : Show Host name , Date and Total no of collection in database

ice_screenshot_20151210-095749

Second Method to execute .js file

ice_screenshot_20151210-100235

 

 

JAVA FX tutorial and Example

https://github.com/PlusHaze/TrayNotification

http://javafx-demos.googlecode.com/svn-history/r100/trunk/javafx-demos/src/main/java/com/ezest/javafx/demogallery/swingawtintegration/JavaFXOnTrayIconDemo.java

https://gist.github.com/jewelsea/e231e89e8d36ef4e5d8a

https://gist.github.com/jewelsea

STRATEGY PATTERN

Blog at WordPress.com.

Up ↑