Sunday, 17 February 2013

BlueTooth example which scans for available devices

Blue1Activity.java
------------------------
package com.blue;

import android.app.Activity;
import android.bluetooth.BluetoothAdapter;
import android.content.Intent;
import android.os.Bundle;
import android.util.Log;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.Button;
import android.widget.TextView;
import android.widget.Toast;

public class Blue1Activity extends Activity {

    private TextView tv1;
    private Button search;
    private static final int REQUEST_ENABLE_BT = 3;
    private BluetoothAdapter mBluetoothAdapter = null;

    /** Called when the activity is first created. */
    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.main);
        tv1 = (TextView) findViewById(R.id.textView1);
        search = (Button) findViewById(R.id.button1);
        // Get local Bluetooth adapter
        mBluetoothAdapter = BluetoothAdapter.getDefaultAdapter();

        // If the adapter is null, then Bluetooth is not supported
        if (mBluetoothAdapter == null) {
            Toast.makeText(this, "Bluetooth is not available",
                    Toast.LENGTH_LONG).show();
            finish();
            return;

        } else {
            int name = mBluetoothAdapter.getState();

            Log.i("tag", mBluetoothAdapter.STATE_OFF + "");

            if (name == mBluetoothAdapter.STATE_OFF) {
                tv1.setText("blue tooth is off");
                if (!mBluetoothAdapter.isEnabled()) {
                    Intent enableIntent = new Intent(
                            BluetoothAdapter.ACTION_REQUEST_ENABLE);
                    startActivityForResult(enableIntent, REQUEST_ENABLE_BT);
                }

            } else if (name == mBluetoothAdapter.STATE_ON) {
                tv1.setText("blue tooth is on");
            }

            Toast.makeText(this, "Bluetooth is  available", Toast.LENGTH_LONG)
                    .show();
        }
        search.setOnClickListener(new OnClickListener() {

            @Override
            public void onClick(View v) {
                // TODO Auto-generated method stub
                Intent intent = new Intent(Blue1Activity.this,
                        paireddevices.class);
                startActivityForResult(intent, 1);

            }
        });
    }

}

Paireddevices.java
-----------------------
package com.blue;

import java.util.Set;

import android.app.Activity;
import android.bluetooth.BluetoothAdapter;
import android.bluetooth.BluetoothDevice;
import android.content.BroadcastReceiver;
import android.content.Context;
import android.content.Intent;
import android.content.IntentFilter;
import android.os.Bundle;
import android.util.Log;
import android.view.View;
import android.view.Window;
import android.view.View.OnClickListener;
import android.widget.AdapterView;
import android.widget.ArrayAdapter;
import android.widget.Button;
import android.widget.ListView;
import android.widget.TextView;
import android.widget.AdapterView.OnItemClickListener;

public class paireddevices extends Activity {
    // Debugging
    private static final String TAG = "DeviceListActivity";
    private static final boolean D = true;

    // Return Intent extra
    public static String EXTRA_DEVICE_ADDRESS = "device_address";

    // Member fields
    private BluetoothAdapter mBtAdapter;
    private ArrayAdapter<String> mPairedDevicesArrayAdapter;
    private ArrayAdapter<String> mNewDevicesArrayAdapter;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);

        // Setup the window
        requestWindowFeature(Window.FEATURE_INDETERMINATE_PROGRESS);
        setContentView(R.layout.device_list);

        // Set result CANCELED in case the user backs out
        setResult(Activity.RESULT_CANCELED);

        // Initialize the button to perform device discovery
        Button scanButton = (Button) findViewById(R.id.button_scan);
        scanButton.setOnClickListener(new OnClickListener() {
            public void onClick(View v) {
                doDiscovery();
                v.setVisibility(View.GONE);
            }
        });

        // Initialize array adapters. One for already paired devices and
        // one for newly discovered devices
        mPairedDevicesArrayAdapter = new ArrayAdapter<String>(this,
                R.layout.device_name);
        mNewDevicesArrayAdapter = new ArrayAdapter<String>(this,
                R.layout.device_name);

        // Find and set up the ListView for paired devices
        ListView pairedListView = (ListView) findViewById(R.id.paired_devices);
        pairedListView.setAdapter(mPairedDevicesArrayAdapter);
        pairedListView.setOnItemClickListener(mDeviceClickListener);

        // Find and set up the ListView for newly discovered devices
        ListView newDevicesListView = (ListView) findViewById(R.id.new_devices);
        newDevicesListView.setAdapter(mNewDevicesArrayAdapter);
        newDevicesListView.setOnItemClickListener(mDeviceClickListener);

        // Register for broadcasts when a device is discovered
        IntentFilter filter = new IntentFilter(BluetoothDevice.ACTION_FOUND);
        this.registerReceiver(mReceiver, filter);

        // Register for broadcasts when discovery has finished
        filter = new IntentFilter(BluetoothAdapter.ACTION_DISCOVERY_FINISHED);
        this.registerReceiver(mReceiver, filter);

        // Get the local Bluetooth adapter
        mBtAdapter = BluetoothAdapter.getDefaultAdapter();

        // Get a set of currently paired devices
        Set<BluetoothDevice> pairedDevices = mBtAdapter.getBondedDevices();

        // If there are paired devices, add each one to the ArrayAdapter
        if (pairedDevices.size() > 0) {
            findViewById(R.id.title_paired_devices).setVisibility(View.VISIBLE);
            for (BluetoothDevice device : pairedDevices) {
                mPairedDevicesArrayAdapter.add(device.getName() + "\n"
                        + device.getAddress());
            }
        } else {
            String noDevices = getResources().getText(R.string.none_paired)
                    .toString();
            mPairedDevicesArrayAdapter.add(noDevices);
        }
    }

    @Override
    protected void onDestroy() {
        super.onDestroy();

        // Make sure we're not doing discovery anymore
        if (mBtAdapter != null) {
            mBtAdapter.cancelDiscovery();
        }

        // Unregister broadcast listeners
        this.unregisterReceiver(mReceiver);
    }

    /**
     * Start device discover with the BluetoothAdapter
     */
    private void doDiscovery() {
        if (D)
            Log.d(TAG, "doDiscovery()");

        // Indicate scanning in the title
        setProgressBarIndeterminateVisibility(true);
        setTitle(R.string.scanning);

        // Turn on sub-title for new devices
        findViewById(R.id.title_new_devices).setVisibility(View.VISIBLE);

        // If we're already discovering, stop it
        if (mBtAdapter.isDiscovering()) {
            mBtAdapter.cancelDiscovery();
        }

        // Request discover from BluetoothAdapter
        mBtAdapter.startDiscovery();
    }

    // The on-click listener for all devices in the ListViews
    private OnItemClickListener mDeviceClickListener = new OnItemClickListener() {
        public void onItemClick(AdapterView<?> av, View v, int arg2, long arg3) {
            // Cancel discovery because it's costly and we're about to connect
            mBtAdapter.cancelDiscovery();

            // Get the device MAC address, which is the last 17 chars in the
            // View
            String info = ((TextView) v).getText().toString();
            String address = info.substring(info.length() - 17);

            // Create the result Intent and include the MAC address
            Intent intent = new Intent();
            intent.putExtra(EXTRA_DEVICE_ADDRESS, address);

            // Set result and finish this Activity
            setResult(Activity.RESULT_OK, intent);
            finish();
        }
    };

    // The BroadcastReceiver that listens for discovered devices and
    // changes the title when discovery is finished
    private final BroadcastReceiver mReceiver = new BroadcastReceiver() {
        @Override
        public void onReceive(Context context, Intent intent) {
            String action = intent.getAction();

            // When discovery finds a device
            if (BluetoothDevice.ACTION_FOUND.equals(action)) {
                // Get the BluetoothDevice object from the Intent
                BluetoothDevice device = intent
                        .getParcelableExtra(BluetoothDevice.EXTRA_DEVICE);
                // If it's already paired, skip it, because it's been listed
                // already
                if (device.getBondState() != BluetoothDevice.BOND_BONDED) {
                    mNewDevicesArrayAdapter.add(device.getName() + "\n"
                            + device.getAddress());
                }
                // When discovery is finished, change the Activity title
            } else if (BluetoothAdapter.ACTION_DISCOVERY_FINISHED
                    .equals(action)) {
                setProgressBarIndeterminateVisibility(false);
                setTitle(R.string.select_device);
                if (mNewDevicesArrayAdapter.getCount() == 0) {
                    String noDevices = getResources().getText(
                            R.string.none_found).toString();
                    mNewDevicesArrayAdapter.add(noDevices);
                }
            }
        }
    };

}

device_list.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/title_paired_devices"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:background="#666"
        android:paddingLeft="5dp"
        android:text="@string/title_paired_devices"
        android:textColor="#fff"
        android:visibility="gone" />

    <ListView
        android:id="@+id/paired_devices"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:layout_weight="1"
        android:stackFromBottom="true" />

    <TextView
        android:id="@+id/title_new_devices"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:background="#666"
        android:paddingLeft="5dp"
        android:text="@string/title_other_devices"
        android:textColor="#fff"
        android:visibility="gone" />

    <ListView
        android:id="@+id/new_devices"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:layout_weight="2"
        scroll=""
        android:stackFromBottom="true" />

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

</LinearLayout>

device_name.xml

<?xml version="1.0" encoding="utf-8"?>
<TextView xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:textSize="18sp"
    android:padding="5dp"
/>

main.xml

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

  

    <TextView
        android:id="@+id/textView1"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:text="TextView" />

    <Button
        android:id="@+id/button1"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:text="Click to see available devices" />

</LinearLayout>

Notifies list immediately when an item is removed or added and updated list is shown(notifydatasetchanged)

Phone.java
package com.example.dynamiclistupdation;

import java.util.ArrayList;
import java.util.List;

import android.app.Activity;
import android.content.Intent;
import android.os.Bundle;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.AdapterView;
import android.widget.AdapterView.OnItemClickListener;
import android.widget.Button;
import android.widget.ListView;
import android.widget.Toast;

public class Phone extends Activity {
      final List<Phonebook> listOfPhonebook = new ArrayList<Phonebook>();
    /** Called when the activity is first created. */
       Phonebook pbClass = new Phonebook();
       final PhonebookAdapter adapter = new PhonebookAdapter(this, listOfPhonebook);
    @Override

    public void onCreate(Bundle savedInstanceState) {

        super.onCreate(savedInstanceState);

        setContentView(R.layout.activity_main);

        ListView list = (ListView) findViewById(R.id.ListView01);
      
        Button bt1 = (Button) findViewById(R.id.button1);
      

        listOfPhonebook.add(new Phonebook("Test", "9981728", "test@test.com"));

        listOfPhonebook.add(new Phonebook("Test1", "1234455", "test1@test.com"));

        listOfPhonebook.add(new Phonebook("Test2", "00000", "test2@test.com"));

    
        bt1.setOnClickListener(new OnClickListener() {
          
            @Override
            public void onClick(View v) {
                // TODO Auto-generated method stub
          
                 
                    Intent my_intent = new Intent(Phone.this, PhoneBookAdd.class);
                  //startActivity(my_intent);
                  
                    startActivityForResult(my_intent, 0);
                     adapter.notifyDataSetChanged();
              
            }
        });
      
     

        list.setClickable(true);

    

      

        list.setOnItemClickListener(new OnItemClickListener() {

            @Override

            public void onItemClick(AdapterView<?> arg0, View view, int position, long index) {

                System.out.println("sadsfsf");

                showToast(listOfPhonebook.get(position).getName());

            }

        });

        list.setAdapter(adapter);
      
 }

    protected void onActivityResult(int requestCode, int resultCode, Intent data) {
                    // TODO Auto-generated method stub
      
                    super.onActivityResult(requestCode, resultCode, data);
                    if(data.getExtras().containsKey("mobile") && (data.getExtras().containsKey("email"))){
                        pbClass.setMail(data.getStringExtra("email"));
                        pbClass.setPhone(data.getStringExtra("mobile"));
                        listOfPhonebook.add(new Phonebook("Test8", pbClass.getPhone(), pbClass.getMail()));
                        adapter.notifyDataSetChanged();
                      
            
                    }
                  
                
                  
                }
  
    private void showToast(String message) {

        Toast.makeText(this, message, Toast.LENGTH_LONG).show();

    }

}



Phonebook.java
package com.example.dynamiclistupdation;

public class Phonebook {

    private String name;

    private String phone;

    private String mail;

 

    // Constructor for the Phonebook class

    public Phonebook(String name, String phone, String mail) {

            super();

            this.name = name;

            this.phone = phone;

            this.mail = mail;

    }

 

    // Getter and setter methods for all the fields.

    // Though you would not be using the setters for this example,

    // it might be useful later.

    public Phonebook() {
        // TODO Auto-generated constructor stub
    }



    public String getName() {

            return name;

    }

    public void setName(String name) {

            this.name = name;

    }

    public String getPhone() {

            return phone;

    }

    public void setPhone(String phone) {

            this.phone = phone;

    }

    public String getMail() {

            return mail;

    }

    public void setMail(String mail) {

            this.mail = mail;

    }

}


package com.example.dynamiclistupdation;

import java.util.List;


import android.content.Context;
import android.content.Intent;
import android.sax.StartElementListener;
import android.view.LayoutInflater;
import android.view.View;
import android.view.View.OnClickListener;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.Button;
import android.widget.TextView;
import android.widget.Toast;

public class PhonebookAdapter extends BaseAdapter implements OnClickListener {

    private Context context;

    private List<Phonebook> listPhonebook;

    public PhonebookAdapter(Context context, List<Phonebook> listPhonebook) {
      

        this.context = context;

        this.listPhonebook = listPhonebook;

    }

    public int getCount() {

        return listPhonebook.size();

    }

    public Object getItem(int position) {

        return listPhonebook.get(position);

    }

    public long getItemId(int position) {

        return position;

    }

    public View getView(int position, View convertView, ViewGroup viewGroup) {
      

        Phonebook entry = listPhonebook.get(position);

        if (convertView == null) {

            LayoutInflater inflater = (LayoutInflater) context

                    .getSystemService(Context.LAYOUT_INFLATER_SERVICE);

            convertView = inflater.inflate(R.layout.phone_row, null);

        }

        TextView tvContact = (TextView) convertView.findViewById(R.id.tvContact);

        tvContact.setText(entry.getName());

        TextView tvPhone = (TextView) convertView.findViewById(R.id.tvMobile);

        tvPhone.setText(entry.getPhone());

        TextView tvMail = (TextView) convertView.findViewById(R.id.tvMail);

        tvMail.setText(entry.getMail());

        // Set the onClick Listener on this button

        Button btnRemove = (Button) convertView.findViewById(R.id.btnRemove);
      
      

        btnRemove.setFocusableInTouchMode(false);

        btnRemove.setFocusable(false);

        btnRemove.setOnClickListener(this);
      
      

        // Set the entry, so that you can capture which item was clicked and

        // then remove it

        // As an alternative, you can use the id/position of the item to capture

        // the item

        // that was clicked.

        btnRemove.setTag(entry);
      

      //  btnAdd.setTag(entry);

        // btnRemove.setId(position);

     

        return convertView;

    }

    @Override

    public void onClick(View view) {

        Phonebook entry = (Phonebook) view.getTag();

        listPhonebook.remove(entry);

        // listPhonebook.remove(view.getId());

       notifyDataSetChanged();
    

    }

    private void showDialog(Phonebook entry) {

        // Create and show your dialog

        // Depending on the Dialogs button clicks delete it or do nothing

    }

}


import java.util.ArrayList;

import java.util.List;

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

public class PhoneBookAdd extends Activity {
    Phonebook addDetails = new Phonebook();
    final List<Phonebook> listOfPhonebook = new ArrayList<Phonebook>();
    PhonebookAdapter adapter;
    Phonebook pbClass = new Phonebook();

    /** Called when the activity is first created. */

    TextView mob,email;
    EditText mobedit , emailedit;
    @Override

    public void onCreate(Bundle savedInstanceState) {
      
        super.onCreate(savedInstanceState);

        setContentView(R.layout.add_layout);
        Button addbtn = (Button) findViewById(R.id.button1);
        mob = (TextView) findViewById(R.id.phone);
        email = (TextView) findViewById(R.id.mail);
      
        mobedit = (EditText) findViewById(R.id.phonenum);
      
        emailedit = (EditText) findViewById(R.id.mailaddress);
        addbtn.setOnClickListener(new OnClickListener() {
          
            @Override
            public void onClick(View v) {
                // TODO Auto-generated method stub
              
               
                showToast("add to list");
              
                Intent intent = getIntent();
              
              
              
              
               
               
              
                intent.putExtra("mobile", mobedit.getText().toString());
              
                intent.putExtra("email", emailedit.getText().toString());
                setResult(RESULT_OK, intent);
                pbClass.setMail(emailedit.getText().toString());
                pbClass.setPhone(mobedit.getText().toString());

                finish();
              
                               
              
              
              
              
              
              
              
                
              
                
              
            }
        });

     

    }
  
    @Override
    public void onBackPressed() {
        // TODO Auto-generated method stub
               
        super.onBackPressed();
    }

    private void showToast(String message) {

        Toast.makeText(this, message, Toast.LENGTH_LONG).show();

    }

}




main.xml

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

    <ListView android:id="@+id/ListView01" android:layout_width="fill_parent"
                android:layout_height="wrap_content"></ListView>

  <Button
        android:id="@+id/button1"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:text="Add an item" />


</LinearLayout>

phone_row.xml

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:id="@+id/LinearLayout01"
    android:layout_width="fill_parent"
    android:layout_height="wrap_content"
    android:orientation="vertical"
    android:paddingLeft="10sp"
    android:paddingRight="10sp"
    android:paddingTop="2sp" >

    <TextView
        android:id="@+id/tvContact"
        android:layout_width="fill_parent"
        android:layout_height="wrap_content"
        android:text="Name"
        android:textSize="16sp"
        android:textStyle="bold"
        android:typeface="sans" >
    </TextView>

    <LinearLayout
        android:id="@+id/LinearLayout02"
        android:layout_width="fill_parent"
        android:layout_height="wrap_content" >

        <TextView
            android:id="@+id/TextView01"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:text="Mobile  "
            android:textSize="13sp"
            android:textStyle="bold" >
        </TextView>

        <TextView
            android:id="@+id/tvMobile"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:text="Number"
            android:textSize="13sp" >
        </TextView>
    </LinearLayout>

    <LinearLayout
        android:id="@+id/LinearLayout02"
        android:layout_width="fill_parent"
        android:layout_height="wrap_content" >

        <TextView
            android:id="@+id/TextView01"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:text="Mail  "
            android:textSize="13sp"
            android:textStyle="bold" >
        </TextView>

        <TextView
            android:id="@+id/tvMail"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_weight="1"
            android:text="Mail"
            android:textSize="13sp" >
        </TextView>

        <Button
            android:id="@+id/btnRemove"
            android:layout_width="wrap_content"
            android:layout_height="40dip"
            android:text="Remove" >
        </Button>
    </LinearLayout>

</LinearLayout>

add_layout.xml

<?xml version="1.0" encoding="utf-8"?>

<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"

    android:layout_width="fill_parent"

    android:layout_height="fill_parent"

    android:orientation="vertical" >

    <TextView
        android:id="@+id/phone"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:text="Mobile" />

    <EditText
        android:id="@+id/phonenum"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:ems="10" >

        <requestFocus />
    </EditText>

    <TextView
        android:id="@+id/mail"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:text="TextView" />

    <EditText
        android:id="@+id/mailaddress"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:ems="10"
        android:inputType="textEmailAddress" />

    <Button
        android:id="@+id/button1"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:text="UpdateList" />

</LinearLayout>





Output
------------





Once we click remove button then list is updated immediately:

Program which displays indian currency in german format

import java.text.NumberFormat;

import java.util.Locale;


public class Currency {
    public static void main(String[] args) {
        Locale locale = Locale.GERMANY;
        String string = NumberFormat.getCurrencyInstance(locale).format(123.45);
        System.out.println(string);

    }

}


Output
123,45 €
 

How to display integer or double with the setstring method

Double.toString(age)

Here age is the parameter which contains double value

Friday, 15 February 2013

Java example which replaces character present at particular position

public class StringTest {


    public static void main(String[] args)
    {
        int i =0;
        for(char c: test.toCharArray())
        {
            System.out.println(i++ + "=" + c);
        }
       
        String sample = "akckekghkjklmnopqrstuvwxyz";
        System.out.println(sample);
        char c = sample.charAt(10);
        System.out.println(c);
        System.out.println("test "+sample.substring(0, 10));
        System.out.println(getStringByReplacingTenthPosition(sample).length());

    }

    private static String getStringByReplacingTenthPosition(String sample) {
        return sample.substring(0, 10) + " " + sample.substring(11);
    }
}

Text Bold Effect for android Canvas

Typeface tf = Typeface.DEFAULT_BOLD;
 myPaint.setTypeface(tf);
 myPaint.setTextSize(textFontsize);

Wednesday, 13 February 2013

replace function(replace multiple characters)


public class StringReplace {
    public static void main(String[] args) {
       
        String name = "0namratha.asher";
        if(name.startsWith("0"))
        {
            System.out.println("OMG PLZ COME "+name.replace('0', ' ').replace('.', ' '));
        }
       
    }

}

Monday, 4 February 2013

Sample SqlLite Query Android

 MyDbHelper.java
public class MyDbHelper extends SQLiteOpenHelper {

    private static final String DB_NAME = "mydb";
    private static final int DB_VERSION = 1;

    public static final String TABLE_NAME = "error";
    // public static final int ORIGIN = 1;
    public static final String ORIGIN = "origin";
    public static final String ERROR_STATUS = "eStatus";
    public static final String ERROR_MESSAGE = "eMessage";
    public static final String ERROR_TIMESTAMP = "etimestamp";
    public static final String ERROR_CAUSECODE = "ecausecode";
    public static final String ERROR_DISPLAYCODE = "edisplaycode";
    public static final String ERROR_NOTEID = "enoteid";
    private static final String STRING_CREATE = "CREATE TABLE " + TABLE_NAME
            + " (_id INTEGER PRIMARY KEY AUTOINCREMENT, " + ERROR_STATUS
            + " TEXT, " + ERROR_MESSAGE + " TEXT ," + ERROR_TIMESTAMP
            + " TEXT," + ERROR_CAUSECODE + " TEXT, " + ERROR_DISPLAYCODE
            + " TEXT, " + ORIGIN + " TEXT, " + ERROR_NOTEID + " TEXT " + ");";

    public MyDbHelper(Context context) {

        super(context, DB_NAME, null, DB_VERSION);
        System.out.println("db initialised");
    }

    @Override
    public void onCreate(SQLiteDatabase db) {
        db.execSQL(STRING_CREATE);

    }

    @Override
    public void onUpgrade(SQLiteDatabase db, int oldVersion, int newVersion) {
        db.execSQL("DROP TABLE IF EXISTS " + TABLE_NAME);
        onCreate(db);
    }
}




mHelper = new MyDbHelper(context);
 mDb = mHelper.getWritableDatabase();

Cursor cur = mDb.rawQuery("SELECT * from " + MyDbHelper.TABLE_NAME,
                    null);
mDb.update(MyDbHelper.TABLE_NAME, cv, MyDbHelper.ERROR_NOTEID
                        + "=?", new String[] { testnoteId });


Cursor curcheck = mDb.rawQuery("SELECT "
                        + MyDbHelper.ERROR_STATUS + ","
                        + MyDbHelper.ERROR_CAUSECODE + ","
                        + MyDbHelper.ERROR_DISPLAYCODE + ","
                        + MyDbHelper.ERROR_MESSAGE + "," + MyDbHelper.ORIGIN
                        + " FROM " + MyDbHelper.TABLE_NAME + " WHERE "
                        + MyDbHelper.ERROR_NOTEID + "=?",
                        new String[] { idshared });


Pass a HashMap from Angular Client to Spring boot API

This example is for the case where fileData is very huge and in json format   let map = new Map<string, string>()      map.set(this.ge...