Wednesday, 10 September 2014

Android GridView Tutorial

Download this project


MainActivity.java

package com.gridviewdemo;

import android.os.Bundle;
import android.support.v7.app.ActionBarActivity;
import android.view.View;
import android.widget.AdapterView;
import android.widget.Toast;
import android.widget.AdapterView.OnItemClickListener;
import android.widget.GridView;


public class MainActivity extends ActionBarActivity {
GridView grid_view;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);
        grid_view = (GridView) findViewById(R.id.gridview);
        grid_view.setAdapter(new ImageAdapter(this));
        grid_view.setOnItemClickListener(new OnItemClickListener() {

@Override
public void onItemClick(AdapterView<?> arg0, View arg1, int arg2,
long arg3) {

Toast.makeText(getBaseContext(), "You click on image "+arg2, Toast.LENGTH_LONG).show();

}

     
        });
    }
}

ImageAdapater.java

package com.gridviewdemo;

import android.content.Context;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.GridView;

import android.widget.ImageView;

public class ImageAdapter extends BaseAdapter {
private Context CTX;
private Integer image_id[] = {R.drawable.sample_0,
R.drawable.sample_1, R.drawable.sample_2,
R.drawable.sample_3,
R.drawable.sample_4,
R.drawable.sample_5,
R.drawable.sample_6,
R.drawable.sample_7
};

public ImageAdapter(Context CTX) {

this.CTX = CTX;
// TODO Auto-generated constructor stub
}

@Override
public int getCount() {

return image_id.length;
}

@Override
public Object getItem(int arg0) {
// TODO Auto-generated method stub
return null;
}

@Override
public long getItemId(int arg0) {
// TODO Auto-generated method stub
return 0;
}

@Override
public View getView(int arg0, View arg1, ViewGroup arg2) {
ImageView img;
if(arg1 == null)
{
img = new ImageView(CTX);
img.setLayoutParams(new GridView.LayoutParams(160,160));
img.setScaleType(ImageView.ScaleType.CENTER_CROP);
img.setPadding(8, 8, 8, 8);

}
else
{
img = (ImageView) arg1;
}

img.setImageResource(image_id[arg0]);
return img;


// TODO Auto-generated method stub
// return null;
}


}


activity_main.xml

<GridView 
    xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:tools="http://schemas.android.com/tools"
   android:id="@+id/gridview"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:columnWidth="90dp"
    android:numColumns="auto_fit"
    android:verticalSpacing="10dp"
    android:stretchMode="columnWidth"
    android:gravity="center"
    >

   
</GridView>



Sunday, 7 September 2014

Where To Find Free Blogger Backgrounds and Textures

Blogger is a fantastic tool for amateur and professional writers that have a passion for publishing online content. Unlike WordPress or hosting companies that require you to design your site before ever getting started, Blogger is a ready to go service right out of the box that will allow you to start writing for yourself or others on day one. The effort required to sign up for an account is minimal, and you can really get as creative as you want, whenever you want.

Even if you aren't familiar with web development or design, that's okay. Blogger is a place for everyone. Thanks to the overwhelming support of the Blogger and creative communities, there are plenty of free to use resources out there to make your site look great and keep you focused on what you love best. Here are some of the top sites for acquiring blogger backgrounds that won't cost you a dime and will look incredible.

free blogger backgrounds and textures

Shabby Blogs

Shabby blogs offers some unique texture and graphic rendered Blogger backgrounds to choose from. All of the designs that they have are created to be standard width so you don't get a lot of flexibility to choose from; however, there are guides out there that can teach you how to extend the sidebars, header, and footer of your screen if you find one you love and this is something important to you. In addition to offering Blogger backgrounds Shabby blogs also has a section for cute little buttons that you can add to your site to give it an extra special touch.

shabby blogs backgroundshttp://www.shabbyblogs.com/backgrounds.htmlhttp://www.shabbyblogs.com/backgrounds.htmlhttp://www.shabbyblogs.com/backgrounds.html

Hot Bliggity Blog

Aside from having one of the coolest and creative names to say out loud, Hot Bliggity Blog has a wide selection of patterned-based blogs for your site. You can choose between different color schemes, and they also offer three different sizes to pick from, standard, widened, and full width. Best of all, they are really easy to install. All you have to do is click on the install link underneath the image. From there it will copy the code for you into your clipboard and give you instructions on where to paste it.

hot bliggity blog backgroundshttp://hotbliggityblog.com/http://hotbliggityblog.com/

Dotty Dot Dot

Dotty Dot is the place to go if you like geometric type backgrounds that are heavy on squares, plaid, circles, and of course dots. The website is a little bit hard to navigate, but they have a sidebar with a bunch of tags to help you sort through all the available templates and find something you like. Just about every color you can imagine is available if you plan on matching your Blogger backgrounds to your favorite color or font style. The widths of the most of the templates vary so some have heavy padded sidebars, whereas some are very skinny.

http://dottydotdotdesign1.blogspot.com/http://dottydotdotdesign1.blogspot.com/http://dottydotdotdesign1.blogspot.com/http://dottydotdotdesign1.blogspot.com/

LeeLou Blogs

Lee Lou Blogs offers Blogger backgrounds that look a lot like you would find in a scrapbook with a heavy dependency on small pictures and vector graphics. These free templates would go great with any home improvement blog or DIY arts and crafts writer. Most of the free backgrounds are standard size with the high padded sides, but like anything you can get access to more templates if you want to take advantage of any of his premium designs.

http://leelou-blogs.com/

CgTextures

If you just want something basic real basic that won't distract customers from your content, you can head over to CgTextures. Their site is full of photos and textures that could be added as a background image with a reduced transparency. The blog would still look great and you wouldn't have to worry as much about trying to match your font style and color so that it fits in with the background. Instead you can draw more focus on what's important and less on the site's bells and whistles.

cg textures for blogger backgrounds

Every Stock Photo

Bloggers that want less of an 'artsy' look to their site and instead more of a serious appeal can get a picture from Every Stock Photo to use as the background image. You can also benefit by using some of the pictures offered through this site within your blog posts so that you aren't stuck buying things from premium image providers. There search bar and navigation panel makes it easy to find exactly what you are looking for to see a unique feel to every page.

every stock photo background image

Shizoo-Design

Shizoo-Design is a German based design firm with about 554 different patterns to choose from. You can find everything from conservative shapes to abstract rainbows and splashes of color. All of the textures are provided in a range of size, anywhere from 1000x700 pixels to 1300x600 pixels so that they will comfortably fit your entire site's background and work with most browsers and computer screen sizes. Brushes and custom icons are also available from the site, free of charge.

shizoo design textures,blogger backgrounds

Patterns of Change

Patterns of Changes offers Blogger backgrounds that are cartoon oriented and that can best be tiled across the screen. The site is perhaps one of the easiest to use compared to all the others on the screen, providing a simple navigation bar where you can choose what color you'd like the pattern to be. When you select one of the colors provided, it will come up with a bunch of different patterns usually associated with that color. For instance, when the color brown is selected, one of the choices ia brown cake. Blogger backgrounds for this site might not be the best choice for business professionals, but they certainly are fun.

patterns of change blogger backgrounds

How to Add a Background Image using the Blogger Template Designer

If you have a background image that you want to upload, then follow these steps:

1. Log into your Blogger account and go to "Template", press the "Customize" button on the right side. Once the Blogger template designer has opened, you'll see the Background option on the left - click on it:

change blogger background

2. Now click on the box below the Background image title and it will open a window from where we can select a default background image. On the upper left side of this window, click Upload Image and select the image you would like to use from a location on your computer.

upload background image

Note that you should use a JPG, GIF, or PNG image that is no more than 300k in size. If your image is too large, then you can use the Kraken.io image optimizer to make the image file smaller.

3. After you've uploaded your image, click 'Done' and you'll be taken back to the background menu. Here you will see additional options like: "Alignment", "Tile" and "Scroll with page":
  • Alignment: change the position of the background image to start either horizontal (left, center, right) or vertical (top and bottom);
  • Tile (Repeat): if you want a small background image to fill the page, choose to repeat (tile) horizontally and/or vertically.
  • Scroll with page: the box is checked by default, this means that the background scroll along with the page contents. If you want the background picture to not move as the page is scrolled and stay exactly where it is, uncheck this box.
background image position

4. For a background image with plain color in the middle for content, you might want to remove the main and header background. Navigate to "Advanced" > "Backgrounds" and type the word "transparent" inside the "Main Background" and "Header Background" box:

change background color

5. If the background is smaller than the content area, we can fix this using CSS. Scroll down and click on the Add CSS option, then paste this CSS code inside the box:
body {
background-size: 200%;
}

.body-fauxcolumn-outer .cap-top {
background: none;
}
Note: to change the size of the background, modify the 200% value in red.

change background size

Once you're happy with the results, press the 'Apply to blog' button and enjoy the new background for your site.

How to Change Background in a Custom Blogger Template

Sometimes the above options might not appear in some custom Blogger templates if the body.background variable hasn't been defined. In this case, we will need to access the HTML of the template:

1. Go to "Template" and click the "Edit HTML" button, then click anywhere inside the code area. Press the CTRL + F keys to open the Blogger search box:

blogger template html

2. Paste or type the following tag inside the search box and hit Enter to find it:
]]></b:skin>
3. Immediately before the ]]></b:skin> tag, paste one of the following code snippets:

For a large background image:
body {
background-image: url(IMAGE-URL.png) !important;
background-repeat: no-repeat;
background-position: center top;
background-attachment: fixed;
background-size: 100%;
}
Note: the no-repeat value prevents the image from repeating either vertically or horizontally. Use background-repeat: repeat-y if you'd like the image to repeat vertically, or background-repeat: repeat-x if you want it to repeat only horizontally. To increase the size of the background, change the 100% value.

adding background in blogger

If using a repeating pattern, add this CSS code instead:
body {
background-image: url(IMAGE-URL.png) !important;
background-repeat: repeat;
background-position: center top;
background-attachment: fixed;
}
4. Open a new tab and upload your background image to Blogger or an image hosting site, and copy the URL of your hosted image to your clipboard. If you don't know how to do it, please take a look at this tutorial.

After you copied it, replace the text highlighted in blue from above with your image url.

5. Finally, Preview the template to ensure that the background image appears as you want, and press the "Save template" button to save your changes. That's it!

Using the 8 sites listed above, you have a wide range to choose from when creating a site that really represents you. Given the right tools, designing you blog can be a fun hobby to enjoy that can spark your creativity and improve the quality of your writing. With such a large selection, the hardest part of setting up your new theme will be finding which one you like best.

Saturday, 6 September 2014

How To Add an Instagram Widget in a Blogger Blog

If you're not familiar with Instagram, it's a photo-sharing network that can be downloaded to your smart phone as an application. Think of it as Facebook without the status updates. By developing a simple service that does one thing, and does it well, Instagram has become one of the most prominent photo sharing apps on the market.

The great thing about using Instagram is that it's not just for individuals. Businesses and non-profits alike can take advantage of this service to share their day and passions with their dedicated customers and fans. These fans number nearly 200 million active users a month, and approximately 7.3 million new daily posts. That's an astonishing number of potential new customers available for you to capture.

By adding Instagram on Blogger as a widget, you can unleash a new visual aspect of that site and allow visitors to go beyond just words on a page. With the convenience to carry the application around on your smartphone wherever you go, you can snap pictures, apply filters, and upload that content to your profile. From the profile, a widget specially designed for Instagram on Blogger would translate that data and display the image on your site. Even those visitors that aren't members of Instagram could benefit from such a service.

It doesn't matter what you are sharing. Whether you're the type of person that loves to share pictures of your dinner with the world, or business owner that loves showcasing their brand in everyday life, Instagram can work for you. Adding Instagram on Blogger as a widget also offers an incredibly accessible tool for stock photos to use in new posts.

This guide will explain how to add an Instagram widget to your site with step-by-step instructions. The design of your new Instagram widget is entirely customizable and will allow you to modify the background color, font, and how the widget is actually displayed on the site. When you're finished, you'll find that the Instagram widget will blend together effortlessly with your current theme and make your Blogger site truly stand out from the rest.
instagram widget in blogger

How to Add An Instagram Widget in Blogger

1. To get the Instagram widget, access the Intagme website here: http://www.intagme.com/

2. Type in your username > select Grid or Slideshow:

instagme username setting

3. Select the Thumbnail size of your images (100px is the default) and choose if you want a border around your Photos or not

instagram widget thumbnail

4. To change the Background Color, simply click on the empty box and pick your favorite color

instagram background color

5. If you want to show the Sharing buttons on your widget, select 'Yes', otherwise, click 'No'.

6. Once you're satisfied with the widget, press the "Get Code" button and copy your code.

instagram sharing buttons

7. Log into your Blogger account and select your blog > navigate to Layout and click on the "Add a Gadget" link on the right side:

adding instagram to blogger

8. In the pop-up window, scroll down and click on the "HTML/JavaScript" gadget:

add html javascript gadget

9. Paste the code that you got from the Intagme website into the content section and press the 'Save' button to save the widget.

instagram code to blogger

10. Click and drag your widget if you want to change its position and press the "Save Arrangement" button on the upper right side.

blogger save arrangement

And that's it! Now you have your very own Instagram widget on your Blogger blog to share new photos with visitors, and provide just a glimpse of your life when you're away from the computer. To change or add any of the photos that are displayed in the widget, you'll have to go directly through the app itself, or log on to your account via Instagram's website.

Once you're ready to show off your new work, let all your customers or fans know by posting a Facebook link to the site or a tweet about the changes and asking them to follow you. Just make sure that you've added a few photos before making the announcement, so that they have something to look at. After they access your widget, they can like your new photos and interact with you in entirely new ways.

Android SQLite Database Operations

MainActivity.java

package com.firstapp;

import android.content.Intent;
import android.os.Bundle;
import android.support.v7.app.ActionBarActivity;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.Button;


public class MainActivity extends ActionBarActivity {
Button Login, Register, Delete, Update;
int status = 0;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);
        Login = (Button) findViewById(R.id.Login);
        Register = (Button) findViewById(R.id.Reg);
        Delete = (Button) findViewById(R.id.Delete);
        Update = (Button) findViewById(R.id.Update);
        Login.setOnClickListener(new OnClickListener() {
@Override
public void onClick(View arg0) {
status = 1;
Bundle b = new Bundle();
b.putInt("status", status);
Intent i  = new Intent("login_filter");
i.putExtras(b);
startActivity(i);
}
});
        
        Register.setOnClickListener(new OnClickListener() {
@Override
public void onClick(View v) {
// TODO Auto-generated method stub
Intent i  = new Intent("register_filter");
startActivity(i);
}
});
        Update.setOnClickListener(new OnClickListener() {
@Override
public void onClick(View arg0) {
status = 2;
Bundle b = new Bundle();
b.putInt("status", status);
Intent i  = new Intent("login_filter");
i.putExtras(b);
startActivity(i);
}
});
        Delete.setOnClickListener(new OnClickListener() {
@Override
public void onClick(View arg0) {
status = 3;
Bundle b = new Bundle();
b.putInt("status", status);
Intent i  = new Intent("login_filter");
i.putExtras(b);
startActivity(i);
}
});
    }
}


LoginActivity.java

package com.firstapp;

import android.app.Activity;
import android.content.Context;
import android.content.Intent;
import android.database.Cursor;
import android.os.Bundle;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.Button;
import android.widget.EditText;
import android.widget.Toast;

public class LoginActivity extends Activity {
Button Login;
EditText USERNAME,USERPASS;
String username,userpass;
Context CTX = this;
@Override
protected void onCreate(Bundle savedInstanceState) {
// TODO Auto-generated method stub
super.onCreate(savedInstanceState);
setContentView(R.layout.login_layout);
Login = (Button) findViewById(R.id.b_login);
USERNAME = (EditText) findViewById(R.id.user_name);
USERPASS = (EditText) findViewById(R.id.user_pass);
Login.setOnClickListener(new OnClickListener() {
@Override
public void onClick(View arg0) {
Bundle b = getIntent().getExtras();
int status = b.getInt("status");
if(status == 1)
{
Toast.makeText(getBaseContext(), "Please wait...", Toast.LENGTH_LONG).show();
username = USERNAME.getText().toString();
userpass = USERPASS.getText().toString();
DatabaseOperations DOP = new DatabaseOperations(CTX);
Cursor CR = DOP.getInformation(DOP);
CR.moveToFirst();
boolean loginstatus = false;
String NAME = "";
do
{
if(username.equals(CR.getString(0))&& (userpass.equals(CR.getString(1))))
{
loginstatus = true;
NAME = CR.getString(0);
}
}while(CR.moveToNext());
if(loginstatus)
{
Toast.makeText(getBaseContext(), "Login Success----\n Welcome "+NAME, Toast.LENGTH_LONG).show();
   finish();
}
else
{
Toast.makeText(getBaseContext(), "Login Failed---- ", Toast.LENGTH_LONG).show();
   finish();
}
}
else if(status == 2)
{
Toast.makeText(getBaseContext(), "Please wait...", Toast.LENGTH_LONG).show();
username = USERNAME.getText().toString();
userpass = USERPASS.getText().toString();
DatabaseOperations DOP = new DatabaseOperations(CTX);
Cursor CR = DOP.getInformation(DOP);
CR.moveToFirst();
boolean loginstatus = false;
String NAME = "";
do
{
if(username.equals(CR.getString(0))&& (userpass.equals(CR.getString(1))))
{
loginstatus = true;
NAME = CR.getString(0);
}
}while(CR.moveToNext());
if(loginstatus)
{
Toast.makeText(getBaseContext(), "Login Success----\n Welcome "+NAME, Toast.LENGTH_LONG).show();
  
Intent i = new Intent("update_filter");
Bundle BN = new Bundle();
BN.putString("user_name",NAME );
BN.putString("user_pass",userpass );
i.putExtras(BN);
startActivity(i);
finish();
}
else
{
Toast.makeText(getBaseContext(), "Login Failed---- ", Toast.LENGTH_LONG).show();
   finish();
}
}
else if(status == 3)
{
Toast.makeText(getBaseContext(), "Please wait...", Toast.LENGTH_LONG).show();
username = USERNAME.getText().toString();
userpass = USERPASS.getText().toString();
DatabaseOperations DOP = new DatabaseOperations(CTX);
Cursor CR = DOP.getInformation(DOP);
CR.moveToFirst();
boolean loginstatus = false;
String NAME = "";
do
{
if(username.equals(CR.getString(0))&& (userpass.equals(CR.getString(1))))
{
loginstatus = true;
NAME = CR.getString(0);
}
}while(CR.moveToNext());
if(loginstatus)
{
Toast.makeText(getBaseContext(), "Login Success----\n Welcome "+NAME, Toast.LENGTH_LONG).show();
Intent i = new Intent("delete_filter");
Bundle B = new Bundle();
B.putString("user_name",NAME );
i.putExtras(B);
startActivity(i);
finish();
}
else
{
Toast.makeText(getBaseContext(), "Login Failed---- ", Toast.LENGTH_LONG).show();
   finish();
}
//Intent i = new Intent("delete_filter");
//startActivity(i);
}
}
});
}

}


RegisterActivity.java

package com.firstapp;

import android.app.Activity;
import android.content.Context;
import android.os.Bundle;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.Button;
import android.widget.EditText;
import android.widget.Toast;

public class RegisterActivity extends Activity {
EditText USER_NAME,USER_PASS,CON_PASS;
String user_name,user_pass,con_pass;
Button REG;
Context ctx = this;
@Override
protected void onCreate(Bundle savedInstanceState) {
// TODO Auto-generated method stub
super.onCreate(savedInstanceState);
setContentView(R.layout.register_layout);
USER_NAME = (EditText) findViewById(R.id.reg_user);
USER_PASS = (EditText) findViewById(R.id.reg_pass) ;
CON_PASS = (EditText) findViewById(R.id.con_pass);
REG = (Button) findViewById(R.id.user_reg);
REG.setOnClickListener(new OnClickListener() {
@Override
public void onClick(View v) {
user_name = USER_NAME.getText().toString();
user_pass = USER_PASS.getText().toString();
con_pass = CON_PASS.getText().toString();
if(!(user_pass.equals(con_pass)))
{
Toast.makeText(getBaseContext(),"Passwords are not matching", Toast.LENGTH_LONG).show();
   USER_NAME.setText("");
   USER_PASS.setText("");
   CON_PASS.setText("");
}
else
{
DatabaseOperations DB = new DatabaseOperations(ctx);
DB.putInformation(DB, user_name, user_pass);
Toast.makeText(getBaseContext(), "Registration success", Toast.LENGTH_LONG).show();
finish();
}
}
});
}

}

DeleteActivity.java

package com.firstapp;

import android.app.Activity;
import android.content.Context;
import android.database.Cursor;
import android.os.Bundle;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.Button;
import android.widget.EditText;
import android.widget.Toast;

public class DeleteActivity extends Activity {
Bundle bn;
String USERNAME;
Button Del;
EditText PASS;
String Pass;
DatabaseOperations DOP;
Context CTX = this;
@Override
protected void onCreate(Bundle savedInstanceState) {
// TODO Auto-generated method stub
super.onCreate(savedInstanceState);
setContentView(R.layout.delete_layout);
Del = (Button) findViewById(R.id.b_delete);
PASS = (EditText) findViewById(R.id.del_pass);
bn = getIntent().getExtras();
USERNAME = bn.getString("user_name");
Del.setOnClickListener(new OnClickListener() {
@Override
public void onClick(View v) {
// TODO Auto-generated method stub
Pass = PASS.getText().toString();
DOP = new DatabaseOperations(CTX);
Cursor CR = DOP.getUserPass(DOP, USERNAME);
CR.moveToFirst();
boolean login_status = false;
do
{
if(Pass.equals(CR.getString(0)))
{
login_status = true;
}
}while(CR.moveToNext());
if(login_status)
{
DOP.deleteUser(DOP,USERNAME , Pass);
Toast.makeText(getBaseContext(), "User Removed successfully.....", Toast.LENGTH_LONG).show();
finish();
}
else
{
Toast.makeText(getBaseContext(), "Invalid user.....Try later", Toast.LENGTH_LONG).show();
   finish();
}
}
});
}

}


UpdateActivity.java

package com.firstapp;

import android.app.Activity;
import android.content.Context;
import android.os.Bundle;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.Button;
import android.widget.EditText;
import android.widget.Toast;

public class UpdateActivity extends Activity {
String user_name,user_pass,New_user_name;
Button b_update;
EditText newuser;
Context CTX = this;
DatabaseOperations DOP;
@Override
protected void onCreate(Bundle savedInstanceState) {
// TODO Auto-generated method stub
super.onCreate(savedInstanceState);
setContentView(R.layout.update_layout);
Bundle BN = getIntent().getExtras();
user_name = BN.getString("user_name");
user_pass = BN.getString("user_pass");
b_update = (Button) findViewById(R.id.b_update);
newuser = (EditText) findViewById(R.id.new_user_name);
b_update.setOnClickListener(new OnClickListener() {
@Override
public void onClick(View v) {
New_user_name = newuser.getText().toString();
DOP = new DatabaseOperations(CTX);
DOP.updateUserInfo(DOP, user_name, user_pass, New_user_name);
Toast.makeText(getBaseContext(), "Updation Success.....", Toast.LENGTH_LONG).show();
   finish();
}
});
}

}


DatabaseOperations.java

package com.firstapp;

import com.firstapp.TableData.TableInfo;

import android.content.ContentValues;
import android.content.Context;
import android.database.Cursor;
import android.database.sqlite.SQLiteDatabase;
import android.database.sqlite.SQLiteDatabase.CursorFactory;
import android.database.sqlite.SQLiteOpenHelper;
import android.provider.SyncStateContract.Columns;
import android.util.Log;

public class DatabaseOperations extends SQLiteOpenHelper {
public static final int database_version = 1;
public String CREATE_QUERY = "CREATE TABLE "+TableInfo.TABLE_NAME+"("+TableInfo.USER_NAME+" TEXT,"+TableInfo.USER_PASS+" TEXT);";                              

public DatabaseOperations(Context context) {
super(context, TableInfo.DATABASE_NAME, null, database_version);
Log.d("Database operations", "Database created");
}

@Override
public void onCreate(SQLiteDatabase sdb) {
sdb.execSQL(CREATE_QUERY);
Log.d("Database operations", "Table created");

}

@Override
public void onUpgrade(SQLiteDatabase arg0, int arg1, int arg2) {
// TODO Auto-generated method stub

}
public void putInformation(DatabaseOperations dop,String name,String pass)
{
SQLiteDatabase SQ = dop.getWritableDatabase();
ContentValues cv = new ContentValues();
cv.put(TableInfo.USER_NAME, name);
cv.put(TableInfo.USER_PASS, pass);
long k = SQ.insert(TableInfo.TABLE_NAME, null, cv);
Log.d("Database operations", "One raw inserted");
}
public Cursor getInformation(DatabaseOperations dop)
{
SQLiteDatabase SQ = dop.getReadableDatabase();
String[] coloumns = {TableInfo.USER_NAME,TableInfo.USER_PASS};
Cursor CR = SQ.query(TableInfo.TABLE_NAME,coloumns, null, null, null, null, null);
return CR;
}
public Cursor getUserPass(DatabaseOperations DOP, String user)
{
   SQLiteDatabase SQ = DOP.getReadableDatabase();
   String selection = TableInfo.USER_NAME +" LIKE ?";
   String coloumns[] = {TableInfo.USER_PASS};
   String args[] = {user};
   Cursor CR = SQ.query(TableInfo.TABLE_NAME, coloumns, selection, args, null, null, null);
return CR;
}
public void deleteUser(DatabaseOperations DOP, String user, String pass)
{
String selection = TableInfo.USER_NAME+ " LIKE ? AND "+TableInfo.USER_PASS +" LIKE ?";
//String coloumns[] = {TableInfo.USER_PASS};
String args[] = {user,pass};
SQLiteDatabase SQ = DOP.getWritableDatabase();
SQ.delete(TableInfo.TABLE_NAME, selection, args);
}
public void updateUserInfo(DatabaseOperations DOP, String user_name, String user_pass, String new_user_name )
{
SQLiteDatabase SQ  = DOP.getWritableDatabase();
String selection = TableInfo.USER_NAME+ " LIKE ? AND "+TableInfo.USER_PASS +" LIKE ?";
String args[] = {user_name,user_pass};
ContentValues values = new ContentValues();
values.put(TableInfo.USER_NAME, new_user_name);
SQ.update(TableInfo.TABLE_NAME, values, selection, args);
}

}

TableData,java

package com.firstapp;

import android.provider.BaseColumns;

public class TableData {
public TableData()
{
}
public static abstract class TableInfo implements BaseColumns
{
public static final String USER_NAME = "user_name" ;
public static final String USER_PASS = "user_pass" ;
public static final String DATABASE_NAME = "userdb97";
public static final String TABLE_NAME = "regtb97";
}

}


activity_main.xml

<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:tools="http://schemas.android.com/tools"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:paddingBottom="@dimen/activity_vertical_margin"
    android:paddingLeft="@dimen/activity_horizontal_margin"
    android:paddingRight="@dimen/activity_horizontal_margin"
    android:paddingTop="@dimen/activity_vertical_margin"
    tools:context="com.firstapp.MainActivity" >

    <Button
        android:id="@+id/Login"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:layout_alignLeft="@+id/Reg"
        android:layout_alignParentTop="true"
        android:layout_marginTop="18dp"
        android:text="Login" />

    <Button
        android:id="@+id/Delete"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:layout_alignLeft="@+id/Update"
        android:layout_below="@+id/Update"
        android:layout_marginTop="46dp"
        android:text="Delete User" />

    <Button
        android:id="@+id/Reg"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:layout_alignLeft="@+id/Update"
        android:layout_below="@+id/Login"
        android:layout_marginTop="23dp"
        android:text="Register" />

    <Button
        android:id="@+id/Update"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:layout_below="@+id/Reg"
        android:layout_centerHorizontal="true"
        android:layout_marginTop="16dp"
        android:text="Update Info" />

</RelativeLayout>

login_layout.xml

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:orientation="vertical" >

    <EditText
        android:id="@+id/user_name"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:ems="10"
        android:hint="Enter User name"
         >

        <requestFocus />
    </EditText>

    <EditText
        android:id="@+id/user_pass"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:ems="10"
        android:inputType="textPassword" 
        android:hint="Enter password"
        />

    <Button
        android:id="@+id/b_login"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:text="Login" />

</LinearLayout>

register_layout.xml

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:orientation="vertical" >

    <EditText
        android:id="@+id/reg_user"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:ems="10"
        android:hint="Enter User name"
         >

        <requestFocus />
    </EditText>

    <EditText
        android:id="@+id/reg_pass"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:ems="10"
        android:inputType="textPassword"
        android:hint="Enter password"
         />

    <EditText
        android:id="@+id/con_pass"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:ems="10"
        android:inputType="textPassword" 
        android:hint="Confirm Password"
        />

    <Button
        android:id="@+id/user_reg"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:text="Register" />

</LinearLayout>

delete_layout.xml

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:orientation="vertical" >

    <TextView
        android:id="@+id/textView1"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:text="Hi User Delete your account from here" />

    <EditText
        android:id="@+id/del_pass"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:ems="10"
        android:hint="Enter your password here"
        android:inputType="textPassword" />

    <Button
        android:id="@+id/b_delete"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:text="Delete Account" />

</LinearLayout>

update_layout.xml

<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="match_parent"
    android:layout_height="match_parent" >

    <TextView
        android:id="@+id/infotext"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:layout_alignParentLeft="true"
        android:layout_alignParentTop="true"
        android:layout_marginLeft="24dp"
        android:text="hello User Update user name Here" />

    <EditText
        android:id="@+id/new_user_name"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:layout_alignLeft="@+id/infotext"
        android:layout_below="@+id/infotext"
        android:layout_marginTop="25dp"
        android:ems="10"
        android:hint="Enter a New User name"
         >

        <requestFocus />
    </EditText>

    <Button
        android:id="@+id/b_update"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:layout_alignParentLeft="true"
        android:layout_below="@+id/new_user_name"
        android:layout_marginTop="20dp"
        android:text="Update " />

</RelativeLayout>















Friday, 5 September 2014

Analysing Android files



In this post I'll simply be listing several tools to analyse (malicious) Android files. 

All tools or scanners listed are free to use.

If you wish to analyze files from the Google Play store without actually installing/downloading them directly to your phone (or, for example, you don't use Android):


If you know of other free tools or scanners for Android files (.apk, .dex), do let me know.



Online tools


AndroTotal









http://andrototal.org/




Anubis (currently discontinued)




http://anubis.iseclab.org/





Apk Analyzer





http://www.apk-analyzer.net/



Apk-deguard









http://apk-deguard.com/






ApkScan











http://apkscan.nviso.be/




Android APK Decompiler







http://www.decompileandroid.com/




AVC UnDroid










http://www.av-comparatives.org/avc-analyzer/



CopperDroid










http://copperdroid.isg.rhul.ac.uk/copperdroid/




Fallible




https://android.fallible.co/



Judge






http://judge.rednaga.io/





Koodous




https://koodous.com/




Reverse.it (Hybrid Analysis)















https://www.reverse.it/



SandDroid







http://sanddroid.xjtu.edu.cn/#





VirusTotal









https://www.virustotal.com/en/






Offline tools


AndroGuard




https://github.com/androguard/androguard/




Androl4b



https://github.com/sh4hin/Androl4b




Android-apktool (APKtool)





https://ibotpeaches.github.io/Apktool/




Android SDK





 http://developer.android.com/sdk/index.html



Android Tamer












https://androidtamer.com/




APKiD






https://github.com/rednaga/APKiD



Apkinspector






https://github.com/honeynet/apkinspector/




CuckooDroid









https://github.com/idanr1986/cuckoo-droid




Dex2jar





http://code.google.com/p/dex2jar/ ( + JD-Gui)




Lobotomy 





https://github.com/LifeForm-Labs/lobotomy



Mobile Security Framework (MobSF)








https://github.com/MobSF/Mobile-Security-Framework-MobSF