example Archives - wiki

Android GreenDAO Example

There are two step required for implementing Green Dao ORM library in to android project

1. Create generator java module
2. Implement data base interaction in Activity

Step 1. Create generator java module

The generator module contains a single class containing the data model definition. This will automatically generate model class and Dao calss for the database interaction

How to create a generator module?

In android studio got File->New-> New Module select Java Library 

javalib

Give library name and class name

javalib2

After adding the library the folder structure will be like this

befouremoduleexe

add GreenDao dependency in the created module, and sync

for Green dao 3.x please use the plugin

generatergradile

Add the following code in GeneratorClass.java file. Here we defining a users table scema

for Green dao 3.x:- just change the imports

Run GeneratorClass.java file

rungenerator

It will Create a db folder inside out main app package

aftermoduleexe

 

2. Implement data base interaction in Activity

Add Green Dao gradle dependency in our main project and sync

for Green dao 3.x:-

appgradle

MainActivity .java

activity_main.xml

Out Put

greendaooutput

 

Note:-

While running you app you need to set app from tine toolbar and run

note

 

Ref:

http://greenrobot.org/greendao/

3 Likes
By bm on September 28, 2016 | Android | A comment?
Tags: , ,

Android RecyclerView Example

Android RecyclerView example using view hodelr in adapter

(For using multiple layout in RecyclerView check this tutorial )

Add ‘com.android.support:recyclerview‘ in Gradle dependencies and sync it

my app/build.gradle file

MainActivity

Model

Adapter

Interface:

Layouts

Recycler View row

Out Put

recyclerview

 

If you want to add data to RecyclerView  add data into the Array List (eg:- usersList.add(new UserModel(“new name”, “345”)); and you can call the adapter function notifyItemInserted() or notifyDatasetChanged().

While editing edit the value in array list and call notifyItemChanged(position), while deleting delete the position from array list and call notifyItemRemoved(position)

 

  Like
By bm on August 30, 2016 | Android | A comment?
Tags: , ,

Nodejs Express GET POST Multipart request handling example

Nodejs Express GET POST Multipart request handling example

Create a new with nodejs and express (check this post for how to create node express project)

Pr-requirements

  1. create an empty folder in root of your application
  2. install requires node packages (I have added all the node packages in package.json so you can simply run npm install it will take care of this)

index.js this is my app entry point.

routes.js :- I have made a separate rout file that’s why the routs.js file (Check this post for how to make separate rout file) otherwise you can directly add this code into your entry point file (in my case index.js)

I am using the multer node package for handing multipart request

home.html

package.json

It is ready open your browser and test it

nodefileupload

You can see the file is uploaded, but it is using some random name for the file.

For changing file name we can make a small configuration changes in routs.js. Insted of  ‘var upload = multer({ dest: ‘./uploads/’ });’ add the new configuration settings

 

 

ref :

http://wiki.workassis.com/installing-express-with-nodejs/

http://wiki.workassis.com/nodejs-express-separate-routes/

https://www.npmjs.com/package/multer

  Like
By bm on August 19, 2016 | Express, NodeJs | A comment?
Tags: , , , , , ,