Delete one single cell from ContactsContract-ContentProvider - android

Hi fellow android programmers,
I wan't my application to delete one single information from a contact and I don't mean one phonenumber or one adress, I actually mean like only the street from the adress or only the job_description from the organization. Technically I won't to delete one cell of one row in the Data-Table of the ContactsContract-ContentProvider.
I red the documentation twice, but they are only talking about whole rows when they describe the insert-, update-, delete-, query-Methods :(
Is anyone aware of how to delete one particular cell? Or am I supposed to update one row with one cell so to "" (empty string)? Or do I even need to read one whole row, set the one cell to "" (empty string) and update the whole row?
Cheers and thanks in advance Ali3n

Do not delete it.. try to update it..
1) add your new value of particular column, like contentValues.put(STREET,"");
2) update the table by using update method. and use a where condition where contact_id = ur id.
PS:column names are not right.

Related

How to get Recently Added / Edited / Deleted contact from Phonebook in android

I making an application in which my requirement is to get the Recently Added or Edited or Deleted Contact in Phonebook. So is there is way to achieve this. Any help will be appreciated.
You need to show what you tried, so that we can write our answers based on your try.
First, make sure you have this:
<uses-permission android:name="android.permission.READ_CONTACTS" />
According to the android docs, you can easily read contacts, and, to get specific selections (which is exactly what you want) you can:
Define a search text expression that retrieves rows for a specific
contact's LOOKUP_KEY and the Data.MIMETYPE of the details you want.
Enclose the MIMETYPE value in single quotes by concatenating a "'"
(single-quote) character to the start and end of the constant;
otherwise, the provider interprets the constant as a variable name
rather than as a string value. You don't need to use a placeholder for
this value, because you're using a constant rather than a
user-supplied value.
Take a look at the different ways to get specific selection keys on contacts, so that you can get exactly what you want.
http://developer.android.com/training/contacts-provider/retrieve-details.html

query where relation contains any object from array

Some time ago i tried to use a BaaS service (parse.com), now I want to make a query to fetch a result set where parse' table contained tag values as "tag1, tag2, tag2"
I found similar question, but it doesn't work fo me, in my case I get row where TAG column equals one of tags item, but not contained one of them
query.whereContainedIn("Tags", Arrays.asList("tag1", "tag2"));
If someone had same issue please help me resolve it or give a correct way to figure it out

How to make number picker with only available numbers?

My app is using api 7. I don't know where to start with this challenge.
I have SQLite DB with some numbers stored between 1-99. Now I would like to make number picker for this range which would also remove numbers that are already in DB.
Create a list off the numbers 0-99, then do a query on your database. For every row in the results from the database, check if the list contains is (something like list.contains(number). If it is there, remove it (list.remove(item)) then proceed to the next row
You'll probably have to make your own widget. This will be somewhat involved, and since you are an Android beginner you might better spend your time coming up with a different input method.
In case you do decide to write your own widget, I would recommend extending LinearLayout, then inside of the constructor, doing something like this psuedocode:
setOrientation(VERTICAL);
addView ImageButton arrowUpButton;
addView EditText numberEditText;
addView ImageButton arrowDownButton;
arrowUpButton.setOnClickListener {
int num = myListOfInts.get(currentIndex++);
numberEditText.setText(num);
}
//vice versa for arrowDownButton
you'd also have to create a setter for the myListOfInts.
Good luck!

Android App , add a favorite quote functionality

I have an android app which displays quotes and have navigation to go to next quote and so on. would like to add "Save Quote As favourite" based on users selection of particular quote.
Once user saves Fav quotes and wants to see those quotes only, app should show those quotes.
Currently app reads the quotes from XML file. Let me know if any more information is required to understand the problem.
I would provide every quote with an ID (int). Whenever the user selects a quote to be a favourite, that ID is saved to a Set of integers. Later on if user decides to show favourites, you fetch all quotes with your IDs from the Set and show them in a appropriate view, for example a ListView
If you have a Quote class or something like that, you might as well put them in a collection whenever user decide his favourites, and show them in a ListView with a custom adapter.

compiling text for textview, including data from SQLite table

A stupid question that Im sure is really really simple - ive been trying to fiddle to solve it myself, but its all very new to me so any wisdom would be REALLY appreciated!
With an android application (using eclipse) if I want to compile text for a text view using some data that is stored in a sqlite database (I have a working dbhelper and table I want to use), what do I do?
For example, I want a text box to say something like:
"hello"+#user_name+"its been"+#days+"since your last visit!"
where #user_name and #days are data in a table which I can currently retreive in a list (only 1 value in the list though).
How do i compile a string to be shown in the text view (and assign this string to the view)?
Help!
String textViewValue="hello "+nameList.get(0)+" its been "+daysList.get(0)+" since youy last visit";
TextView tv = (TextView) findViewById(R.id.textView1);
tv.setText(textViewValue);
You said you have stored it in arryalist right?
I am not sure if you have one ArrayList or two for Name and Days. (it would be good if you paste some of your code).
If your ArrayList is arrayList then you can get the name atleast like
"hello"+arrayList.get(0); // will retrive first element
Or best way use cursor and fire a query which will store output of following in curser
select Name,Days from your_table where Name='xyz';
then you can use folloing code to retrive data form curser (I am assuming there is only one row in cursor here)
if(cursor.moveToFirst()){
String s = "hello"+cursor.getString(0)+"Its been"+cursor.getString(1)+"days since your last visit!!";
}
now set this s in your textbox.

Categories

Resources