I have a strange issue when I create a calendar event programmatically
its always noted as Birthday Calendar (type) I don't have any clue why its noted like that.
My code I use is as below: Xamarin C#
ContentResolver cr = ((Activity)Forms.Context).ContentResolver;
ContentValues values = new ContentValues();
String eventUriString = "content://com.android.calendar/events";
//Insert Events in the calendar...
values.Put(CalendarContract.Events.InterfaceConsts.CalendarId, 1);
values.Put(CalendarContract.Events.InterfaceConsts.Title, title);
values.Put(CalendarContract.Events.InterfaceConsts.Status, 1);
values.Put(CalendarContract.Events.InterfaceConsts.Description, description);
values.Put(CalendarContract.Events.InterfaceConsts.Dtstart, GetDateTimeMS(year, month, day, hour, minute));
values.Put(CalendarContract.Events.InterfaceConsts.Dtend, GetDateTimeMS(year, month, day, hour, minute));
values.Put(CalendarContract.Events.InterfaceConsts.AllDay, allday ? "1" : "0");
values.Put(CalendarContract.Events.InterfaceConsts.HasAlarm, hasalarm ? "1" : "0");
values.Put(CalendarContract.Events.InterfaceConsts.EventColor, Android.Graphics.Color.Green);
values.Put(CalendarContract.Events.InterfaceConsts.EventTimezone, "GMT+" + zone + ":00");
values.Put(CalendarContract.Events.InterfaceConsts.EventEndTimezone, "GMT+" + zone + ":00");
cr.Insert(Android.Net.Uri.Parse(eventUriString), values);
Please does someone has any tips or ideas which can point me to the right direction?
Thanks in advance.
Some devices uses calendar id = 1 for birthdays but generally not. So to get the correct calendar id for particular device (corresponding to the email id configured with calendar app), use below code:
private int getCalendarId(Context context){
Cursor cursor = null;
ContentResolver contentResolver = context.getContentResolver();
Uri calendars = CalendarContract.Calendars.CONTENT_URI;
String[] EVENT_PROJECTION = new String[] {
CalendarContract.Calendars._ID, // 0
CalendarContract.Calendars.ACCOUNT_NAME, // 1
CalendarContract.Calendars.CALENDAR_DISPLAY_NAME, // 2
CalendarContract.Calendars.OWNER_ACCOUNT, // 3
CalendarContract.Calendars.IS_PRIMARY // 4
};
int PROJECTION_ID_INDEX = 0;
int PROJECTION_ACCOUNT_NAME_INDEX = 1;
int PROJECTION_DISPLAY_NAME_INDEX = 2;
int PROJECTION_OWNER_ACCOUNT_INDEX = 3;
int PROJECTION_VISIBLE = 4;
cursor = contentResolver.query(calendars, EVENT_PROJECTION, null, null, null);
if (cursor.moveToFirst()) {
String calName;
long calId = 0;
String visible;
do {
calName = cursor.getString(PROJECTION_DISPLAY_NAME_INDEX);
calId = cursor.getLong(PROJECTION_ID_INDEX);
visible = cursor.getString(PROJECTION_VISIBLE);
if(visible.equals("1")){
return (int)calId;
}
Log.e("Calendar Id : ", "" + calId + " : " + calName + " : " + visible);
} while (cursor.moveToNext());
return (int)calId;
}
return 1;
}
Point to note : IS_PRIMARY_COLOUM which returns 1 in case of email id and not for bithdays and holidays.
Please refer: https://developer.android.com/reference/android/provider/CalendarContract.CalendarColumns.html#IS_PRIMARY for details.
Pkosta is pointing in the right direction.
You have to take the first calendar that is both VISIBLE and IS_PRIMARY.
long calId = 0;
String selection = CalendarContract.Calendars.VISIBLE + " = 1 AND "
+ CalendarContract.Calendars.IS_PRIMARY + " = 1";
Uri calendarUri = CalendarContract.Calendars.CONTENT_URI;
Cursor cur = cr.query(calendarUri, null, selection, null, null);
if (cur != null && cur.moveToFirst()) {
Get the field values
calID = cur.getLong(CalendarContract.Calendars._ID);
}
if (cur != null) {
cur.close();
}
return calId;
The question answered below is old please refer to Pkosta's answer which provides more accurate answer ...
You have to put CalendarId value as 3 instead of 1 which is default birthday calendar.
e.g.
values.Put(CalendarContract.Events.InterfaceConsts.CalendarId, 1);
change it to
values.Put(CalendarContract.Events.InterfaceConsts.CalendarId, 3);
It solved the same issue for me.
Related
Good day guys. I have an query in my app which is called very often, and it takes lot of time. My db is encrypted with SQLiteCipher (I know that costs a lof of performance so I call and open DB only once). So actually i have a listview with a custom adapter which lists die name, lastMassage and the time of the lM. So I have to do this work:
public Massage getLastMassage(String ChatNumber) {
String[] args = {ChatNumber};
//String selectQuery="SELECT * FROM " + MassageDBHelper.DATABASE_NAME + " WHERE PhoneNumber=?";
//Cursor cursor=database.rawQuery(selectQuery,args);
Cursor cursor = database.query(MassageDBHelper.DATABASE_NAME, columns, "PhoneNumber=?", args, null, null, null);
cursor.moveToLast();
Massage massage = cursorToMassage(cursor);
cursor.close();
return massage;
}
That was the code in my databaseHelperClass called MassageDataSource, I've tried also the query string but there are not differences in Performance.
In my CustomAdapter I have to do this for every Chat (every person who was written):
Massage lastMassage = massageDataSource.getLastMassage(kontaktItem.getNummer());
Date date = lastMassage.getTimeAsDate();
cal.setTime(date);
int Jahr = cal.get(Calendar.YEAR);
int Monat = cal.get(Calendar.MONTH);
int Tag = cal.get(Calendar.DAY_OF_MONTH);
int Stunden = cal.get(Calendar.HOUR_OF_DAY);
int Minuten = cal.get(Calendar.MINUTE);
if (Jahr < Kalenderjahr || Monat < Kalendermonat || Tag + 1 < Kalendertag) {
viewHolder.Uhrzeit.setText(String.format("%02d", Tag) + "." + String.format("%02d", Monat) + "." + Jahr % 1000);
} else if (Tag < Kalendertag) {
viewHolder.Uhrzeit.setText(R.string.gestern);
} else {
viewHolder.Uhrzeit.setText(String.format("%02d", Stunden) + ":" + String.format("%02d", Minuten));
}
viewHolder.Kontaktname.setText(kontaktItem.getName());
viewHolder.Chatsnippet.setText(lastMassage.getMassageText());
//set Image from server
return view;
Edit Here is also the cursorToMassage function which is called:
private Massage cursorToMassage(Cursor cursor) {
int idPhoneNumber = cursor.getColumnIndex(MassageDBHelper.COLUMN_PHONENUMBER);
int idType = cursor.getColumnIndex(MassageDBHelper.COLUMN_TYPE);
int idMassagetext = cursor.getColumnIndex(MassageDBHelper.COLUMN_MASSAGETEXT);
int idAttachment = cursor.getColumnIndex(MassageDBHelper.COLUMN_ATTACHMENTID);
int idTime = cursor.getColumnIndex(MassageDBHelper.COLUMN_TIME);
int idPosition = cursor.getColumnIndex(MassageDBHelper.COLUMN_POSITION);
String phoneNumber = cursor.getString(idPhoneNumber);
String type = cursor.getString(idType);
String massagetext = cursor.getString(idMassagetext);
String attachment = cursor.getString(idAttachment);
String time = cursor.getString(idTime);
Boolean position = Boolean.valueOf(cursor.getString(idPosition));
Massage massage;
if (type.equals("text")) {
massage = new Massage(position, massagetext, phoneNumber, time);
} else {
massage = new Massage(position, attachment, type, phoneNumber, time);
}
return massage;
}
Try transaction.
Android Database Transaction
public Massage getLastMassage(String ChatNumber) {
database.beginTransaction();
Massage massage = null;
try {
String[] args = {ChatNumber};
//String selectQuery="SELECT * FROM " + MassageDBHelper.DATABASE_NAME + " WHERE PhoneNumber=?";
//Cursor cursor=database.rawQuery(selectQuery,args);
Cursor cursor = database.query(MassageDBHelper.DATABASE_NAME, columns, "PhoneNumber=?", args, null, null, null);
cursor.moveToLast();
massage = cursorToMassage(cursor);
cursor.close();
} catch {
//Error in between database transaction
} finally {
database.endTransaction();
return massage;
}
}
I am trying to show the call log details in my app but CallLog.Calls.CACHED_NAME is always returning null for some contacts even if it is a saved contact with name. The built-in call log is showing the names for these contacts correctly.
This is my code:
protected customAdapRecent doInBackground(Void... params) {
ContentResolver resolver = context.getContentResolver();
final String[] PROJECTION = new String[] {
// CallLog.Calls.CACHED_LOOKUP_URI,
CallLog.Calls.NUMBER,
CallLog.Calls.CACHED_NAME,
CallLog.Calls.TYPE,
CallLog.Calls.DATE,
CallLog.Calls.DURATION
};
Cursor cursor = resolver.query(CallLog.Calls.CONTENT_URI, PROJECTION, null, null, CallLog.Calls.DATE + " DESC");
if(cursor.getCount() > 0)
{
int iNumber = cursor.getColumnIndex(CallLog.Calls.NUMBER);
int iName = cursor.getColumnIndex(CallLog.Calls.CACHED_NAME);
int iType = cursor.getColumnIndex(CallLog.Calls.TYPE);
int iDate = cursor.getColumnIndex(CallLog.Calls.DATE);
int iDuration = cursor.getColumnIndex(CallLog.Calls.DURATION);
DateFormat datePattern = DateFormat.getDateInstance(DateFormat.FULL);
String number;
String name;
String type;
String date;
String duration;
String contactId;
String callIs = "None";
String prevDate = "";
int callType;
while (cursor.moveToNext())
{
if(cursor.getString(iName) == null)
Log.e("DEBUG: ", "Position: " + cursor.getPosition());
number = cursor.getString(iNumber);
name = cursor.getString(iName);
type = cursor.getString(iType);
String tempdate = cursor.getString(iDate);
Long tempDate = Long.parseLong(tempdate);
date = datePattern.format(tempDate);
if(prevDate.equalsIgnoreCase(date))
{
prevDate = date;
date = "";
}
else
prevDate = date;
//date = new Date(Long.valueOf(strdate));
duration = cursor.getString(iDuration);
callType = Integer.parseInt(type);
switch (callType)
{
case CallLog.Calls.OUTGOING_TYPE:
callIs = "OUT";
recentRow newRowO = new recentRow(number, name, date, duration, callIs);
listItem_recentOut.add(newRowO);
break;
case CallLog.Calls.INCOMING_TYPE:
callIs = "IN";
recentRow newRowI = new recentRow(number, name, date, duration, callIs);
listItem_recentIn.add(newRowI);
break;
case CallLog.Calls.MISSED_TYPE:
callIs = "MISS";
recentRow newRowM = new recentRow(number, name, date, duration, callIs);
listItem_recentMiss.add(newRowM);
break;
}
recentRow newRow = new recentRow(number, name, date, duration, callIs);
//recentRow newRow = new recentRow(number, name, callIs);
listItem_recentAll.add(newRow);
}
cursor.close();
cAdapRecent = new customAdapRecent(context, listItem_recentAll);
}
return cAdapRecent;
}
The Debug statement given in the Log.e() is also printing.
Am I doing something wrong in the lookup? Pls. suggest a way as I am really blocked due to this!
Thanks in advance...
I also came across this strange behavior and figured out that sometimes you can't get name of the contact immediately even though you can get everything else from the CallLog.Calls. What I noticed is that after approximately one hour or so since that call you can fetch name along with all other CallLog.Calls data. Very strange. If you need immediate refresh after call you can get name for the number from ContactsContract like this:
fun getNameForNumber(context: Context, number: String): String? {
var res: String? = null
try {
val resolver = context.contentResolver
val uri = Uri.withAppendedPath(ContactsContract.PhoneLookup.CONTENT_FILTER_URI, Uri.encode(number))
val c = resolver.query(uri, arrayOf(ContactsContract.PhoneLookup.DISPLAY_NAME), null, null, null)
if (c != null) {
if (c.moveToFirst()) {
res = c.getString(c.getColumnIndex(ContactsContract.CommonDataKinds.Phone.DISPLAY_NAME))
}
c.close()
}
} catch (e: Exception) {
e.printStackTrace()
}
return res
}
Strangely, after you fetch one name from the ContactsContract fetching name in the way you did it, through CallLog.Calls.CACHED_NAME, misteriously works.
This is also answer for #PeterB and #shyam002
I am trying to write a simple query that contains a group by and a where clause in greendao however I am getting an error when I add in the where clause . Is there another way to write the where clause so that I can get this to work
I am basically getting the day part of today and subtracting 1 so that I can upload data from the previous day.
public List<AppTimeUsage> LoadAppTimeUsageData() {
List<AppTimeUsage> items = new ArrayList<>();
Calendar calendar = Calendar.getInstance();
int thisDay = calendar.get(Calendar.DAY_OF_MONTH);
int previousDayCheck = thisDay -1 ;
String sqlWhere;
sqlWhere = "WHERE DAY_RECORDED = " + previousDayCheck;
String sql = "SELECT APP_NAME , SUM(APP_TIME_SPENT) , DAY_RECORDED FROM APP_TIME_USAGE " + sqlWhere + " GROUP BY APP_NAME ; ";
Cursor c = appTimeUsageDao.getDatabase().rawQuery(sql, null);
int offset = 0;
int d;
int cd;
String e = "";
while (c.moveToNext()) {
AppTimeUsage atu = new AppTimeUsage(
Long.MIN_VALUE,
new Date(),
c.getInt(1),
c.getString(0),
c.getInt(2)
// break;
);
items.add(atu);
//stats = atu;
}
return items;
}
I have managed to extract contact details from the phone by using ContactContract example I found, but I noticed that most of the people on my phone has a unique id key associated to their emails and phone numbers separately. For example, Alan's contact detail is split up as following when I extract it out from database even though they are for the same person:
key name email phone
20121 Alan alan#gmail.com null
20133 Alan null 04xxxxxxxx
So how does the phone manage the association with all these different keys in the contact (I assume there must be a separate table for it)? Is there any way to obtain this association? Because I can not just try match the name as people can have exactly the same name, you have to keep them separated as how they are stored on your phone contact.
(Or the messed up situation is due to all apps are able to save contact related details into the same database on the phone?)
My code looks like following (I forgot where I get this code from, but getDetailedContactList function is returning a list of contact of the above problem):
public static String CONTACT_ID_URI = ContactsContract.Contacts._ID;
public static String DATA_CONTACT_ID_URI = ContactsContract.Data.CONTACT_ID;
public static String MIMETYPE_URI = ContactsContract.Data.MIMETYPE;
public static String EMAIL_URI = ContactsContract.CommonDataKinds.Email.DATA;
public static String PHONE_URI = ContactsContract.CommonDataKinds.Phone.DATA;
public static String NAME_URI = (Build.VERSION.SDK_INT >= Build.VERSION_CODES.HONEYCOMB) ? ContactsContract.Data.DISPLAY_NAME_PRIMARY : ContactsContract.Data.DISPLAY_NAME;
public static String PICTURE_URI = (Build.VERSION.SDK_INT >= Build.VERSION_CODES.HONEYCOMB) ? ContactsContract.Contacts.PHOTO_THUMBNAIL_URI : ContactsContract.Contacts.PHOTO_ID;
public static String MAIL_TYPE = ContactsContract.CommonDataKinds.Email.CONTENT_ITEM_TYPE;
public static String PHONE_TYPE = ContactsContract.CommonDataKinds.Phone.CONTENT_ITEM_TYPE;
public Cursor getContactCursor(String stringQuery, String sortOrder) {
Log.i(TAG, "+++++++++++++++++++++++++++++++++++++++++++++++++++");
Log.e(TAG, "ContactCursor search has started...");
Long t0 = System.currentTimeMillis();
Uri CONTENT_URI;
if (stringQuery == null)
CONTENT_URI = ContactsContract.Contacts.CONTENT_URI;
else
CONTENT_URI = Uri.withAppendedPath(ContactsContract.Contacts.CONTENT_FILTER_URI, Uri.encode(stringQuery));
String[] PROJECTION = new String[]{
CONTACT_ID_URI,
NAME_URI,
PICTURE_URI
};
String SELECTION = NAME_URI + " NOT LIKE ?";
String[] SELECTION_ARGS = new String[]{"%" + "#" + "%"};
Cursor cursor = getContentResolver().query(CONTENT_URI, PROJECTION, SELECTION, SELECTION_ARGS, sortOrder);
Long t1 = System.currentTimeMillis();
Log.e(TAG, "ContactCursor finished in " + (t1 - t0) / 1000 + " secs");
Log.e(TAG, "ContactCursor found " + cursor.getCount() + " contacts");
Log.i(TAG, "+++++++++++++++++++++++++++++++++++++++++++++++++++");
return cursor;
}
public Cursor getContactDetailsCursor() {
Log.i(TAG, "+++++++++++++++++++++++++++++++++++++++++++++++++++");
Log.e(TAG, "ContactDetailsCursor search has started...");
Long t0 = System.currentTimeMillis();
String[] PROJECTION = new String[]{
DATA_CONTACT_ID_URI,
MIMETYPE_URI,
EMAIL_URI,
PHONE_URI
};
String SELECTION = NAME_URI + " NOT LIKE ?" + " AND " + "(" + MIMETYPE_URI + "=? " + " OR " + MIMETYPE_URI + "=? " + ")";
String[] SELECTION_ARGS = new String[]{"%" + "#" + "%", ContactsContract.CommonDataKinds.Email.CONTENT_ITEM_TYPE, ContactsContract.CommonDataKinds.Phone.CONTENT_ITEM_TYPE};
Cursor cursor = getContentResolver().query(
ContactsContract.Data.CONTENT_URI,
PROJECTION,
SELECTION,
SELECTION_ARGS,
null);
Long t1 = System.currentTimeMillis();
Log.e(TAG, "ContactDetailsCursor finished in " + (t1 - t0) / 1000 + " secs");
Log.e(TAG, "ContactDetailsCursor found " + cursor.getCount() + " contacts");
Log.i(TAG, "+++++++++++++++++++++++++++++++++++++++++++++++++++");
return cursor;
}
public List<ContactViewModel> getDetailedContactList(String queryString) {
/**
* First we fetch the contacts name and picture uri in alphabetical order for
* display purpose and store these data in HashMap.
*/
Cursor contactCursor = getContactCursor(queryString, NAME_URI);
if(contactCursor.getCount() == 0){
contactCursor.close();
return new ArrayList<>();
}
List<Integer> contactIds = new ArrayList<>();
if (contactCursor.moveToFirst()) {
do {
contactIds.add(contactCursor.getInt(contactCursor.getColumnIndex(CONTACT_ID_URI)));
} while (contactCursor.moveToNext());
}
HashMap<Integer, String> nameMap = new HashMap<>();
HashMap<Integer, String> pictureMap = new HashMap<>();
int idIdx = contactCursor.getColumnIndex(CONTACT_ID_URI);
int nameIdx = contactCursor.getColumnIndex(NAME_URI);
int pictureIdx = contactCursor.getColumnIndex(PICTURE_URI);
if (contactCursor.moveToFirst()) {
do {
nameMap.put(contactCursor.getInt(idIdx), contactCursor.getString(nameIdx));
pictureMap.put(contactCursor.getInt(idIdx), contactCursor.getString(pictureIdx));
} while (contactCursor.moveToNext());
}
/**
* Then we get the remaining contact information. Here email and phone
*/
Cursor detailsCursor = getContactDetailsCursor();
HashMap<Integer, String> emailMap = new HashMap<>();
HashMap<Integer, String> phoneMap = new HashMap<>();
idIdx = detailsCursor.getColumnIndex(DATA_CONTACT_ID_URI);
int mimeIdx = detailsCursor.getColumnIndex(MIMETYPE_URI);
int mailIdx = detailsCursor.getColumnIndex(EMAIL_URI);
int phoneIdx = detailsCursor.getColumnIndex(PHONE_URI);
String mailString;
String phoneString;
if (detailsCursor.moveToFirst()) {
do {
/**
* We forget all details which are not correlated with the contact list
*/
if (!contactIds.contains(detailsCursor.getInt(idIdx))) {
continue;
}
if(detailsCursor.getString(mimeIdx).equals(MAIL_TYPE)){
mailString = detailsCursor.getString(mailIdx);
/**
* We remove all double contact having the same email address
*/
if(!emailMap.containsValue(mailString.toLowerCase()))
emailMap.put(detailsCursor.getInt(idIdx), mailString.toLowerCase());
} else {
phoneString = detailsCursor.getString(phoneIdx);
phoneMap.put(detailsCursor.getInt(idIdx), phoneString);
}
} while (detailsCursor.moveToNext());
}
contactCursor.close();
detailsCursor.close();
/**
* Finally the contact list is build up
*/
List<ContactViewModel> contacts = new ArrayList<>();
Set<Integer> emailsKeySet = emailMap.keySet();
Set<Integer> phoneKeySet = phoneMap.keySet();
for (Integer key : contactIds) {
if( (!emailsKeySet.contains(key) && !phoneKeySet.contains(key))
|| (emailMap.get(key) == null && phoneMap.get(key) == null)
|| mContactDB.isContactExisted(key))
{
continue;
}
contacts.add(new ContactViewModel(key, nameMap.get(key), emailMap.get(key)));
}
return contacts;
}
Try below code to fetch contact number of specific person.
ContentResolver cr = getContentResolver();
Cursor cursor = cr.query(Phone.CONTENT_URI, null, Phone.DISPLAY_NAME + "=?", new String[]{contactName}, null);
if(cursor.getCount() > 0){
cursor.moveToFirst();
do {
String number = cursor.getString(mCursor.getColumnIndex(Phone.NUMBER));
}while (cursor.moveToNext() );
}
Android recommends using content resolvers and content providers to provide nicely packaged data between applications. You should probably not go messing around with the database itself, and it was clearly not designed with that in mind (as your experience demonstrates).
Instead, you should use the content resolver to query the Android ContactsContract to find what you need. There is a class called ContactsContract.Contacts that sounds like the entry point for what you need. Each record returned by a query to the class represents a single contact.
See the Content Providers Developer Guide for further details.
I have the below function which I use to query the SQLite Db, put the retrieved records in to an array and return it back.
public String[][] getrecords(){
Log.i("SENDSERVER", "Get Records Called");
SQLiteDatabase sampleDB = this.getReadableDatabase();
Cursor c = sampleDB.rawQuery("SELECT id,welawa,lati,longi FROM " +
TABLE_LOCATIONS + " LIMIT 5", null);
String[][] aryDB = new String[5][4];
int i = 0;
if (c != null ) {
if (c.moveToFirst()) {
do {
String db_id = c.getString(c.getColumnIndex("id"));
String welawa = c.getString(c.getColumnIndex("welawa"));
String latitude = c.getString(c.getColumnIndex("lati"));
String longitude = c.getString(c.getColumnIndex("longi"));
aryDB[i][0] = db_id;
aryDB[i][1] = welawa;
aryDB[i][2] = latitude;
aryDB[i][3] = longitude;
Log.i("SENDSERVER", "Record Added"); //This doesn't get logged
i++;
}while (c.moveToNext());
}
}
Log.i("SENDSERVER", "Return Records");
return aryDB;
}
I try to retrieve the records and use them as below from my service class.
String aryDB[][] = dbh.getrecords();
Log.i("SENDSERVER", "GET DB RECORDS");
int i = 0;
int id = 0;
String welawa = "";
String lati = "";
String longi = "";
while(i < 5){
id = Integer.parseInt(aryDB[i][0]);
welawa = aryDB[i][1];
lati = aryDB[i][2];
longi = aryDB[i][3];
Log.i("SENDSERVERDB", id + " - " + welawa + " - " + lati + " - " + longi);
i++;
}
For some reason the array is not being returned.
My possible guesses are,
1. The defining of the function is wrong. My intention is to return the array.
2. I am getting the db connection / my retrieval code is wrong.
3. Some thing else that my noob brain can't comprehend.
Your help is greatly appreciated guys.
------EDIT
After adding some more logs the app crashes at
Cursor c = sampleDB.rawQuery("SELECT id,welawa,lati,longi FROM " +
TABLE_LOCATIONS + " LIMIT 5", null);
Any issue in my query?
It was a DB issue. Wrong ColumnName used.
The Cursor never returns null when there is no row which the requested conditions, just return a empty Cursor.
You code still has problem when the rawQuery returns 0 rows, cursor won't be null and do while loop will execute at least once.
So there will be problem on this line when the cursor is empty
c.getString(c.getColumnIndex("id"));
Change your code to this:
c.moveToFirst();
while (c.moveToNext())
{
String db_id = c.getString(c.getColumnIndex("id"));
String welawa = c.getString(c.getColumnIndex("welawa"));
String latitude = c.getString(c.getColumnIndex("lati"));
String longitude = c.getString(c.getColumnIndex("longi"));
aryDB[i][0] = db_id;
aryDB[i][1] = welawa;
aryDB[i][2] = latitude;
aryDB[i][3] = longitude;
Log.i("SENDSERVER", "Record Added"); //This doesn't get logged
i++;
}