Content Providers. Sharing data in Android



Download 80,23 Kb.
bet3/4
Sana20.06.2022
Hajmi80,23 Kb.
#683901
1   2   3   4
Bog'liq
mobil ilova mustaqil ta\'lim Jumaboyev Adxam


android:id=”@+id/contactID” android:layout_width=”fill_parent” android:layout_height=”wrap_content” />

main.xml





ProviderActivity.java class, quyidagicha o‘zgartiriladi:
package: your package name here
import: import required classes here
public class ProviderActivity extends ListActivity { public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.main);

ProviderActivity.java


ri allContacts = Uri.parse(“content://contacts/people”); //content provider resource URI
Cursor c; // objects to read data item from resource
if (android.os.Build.VERSION.SDK_INT <11) {
c = managedQuery(allContacts, null, null, null, null);
} else {
CursorLoader cursorLoader = new
CursorLoader(this,allContacts,null,null,null,null); c = cursorLoader.loadInBackground();
}




….
String[] columns = new String[] { ContactsContract.Contacts.DISPLAY_NAME, ContactsContract.Contacts._ID};
int[] views = new int[] {R.id.contactName, R.id.contactID}; SimpleCursorAdapter adapter;
if (android.os.Build.VERSION.SDK_INT <11) { adapter = new SimpleCursorAdapter(
this, R.layout.main, c, columns, views);
} else {
adapter = new SimpleCursorAdapter( this, R.layout.main, c, columns, views,

ProviderActivity.java


CursorAdapter.FLAG_REGISTER_CONTENT_OBSERVER);
}

this.setListAdapter(adapter); }


}




Download 80,23 Kb.

Do'stlaringiz bilan baham:
1   2   3   4




Ma'lumotlar bazasi mualliflik huquqi bilan himoyalangan ©hozir.org 2024
ma'muriyatiga murojaat qiling

kiriting | ro'yxatdan o'tish
    Bosh sahifa
юртда тантана
Боғда битган
Бугун юртда
Эшитганлар жилманглар
Эшитмадим деманглар
битган бодомлар
Yangiariq tumani
qitish marakazi
Raqamli texnologiyalar
ilishida muhokamadan
tasdiqqa tavsiya
tavsiya etilgan
iqtisodiyot kafedrasi
steiermarkischen landesregierung
asarlaringizni yuboring
o'zingizning asarlaringizni
Iltimos faqat
faqat o'zingizning
steierm rkischen
landesregierung fachabteilung
rkischen landesregierung
hamshira loyihasi
loyihasi mavsum
faolyatining oqibatlari
asosiy adabiyotlar
fakulteti ahborot
ahborot havfsizligi
havfsizligi kafedrasi
fanidan bo’yicha
fakulteti iqtisodiyot
boshqaruv fakulteti
chiqarishda boshqaruv
ishlab chiqarishda
iqtisodiyot fakultet
multiservis tarmoqlari
fanidan asosiy
Uzbek fanidan
mavzulari potok
asosidagi multiservis
'aliyyil a'ziym
billahil 'aliyyil
illaa billahil
quvvata illaa
falah' deganida
Kompyuter savodxonligi
bo’yicha mustaqil
'alal falah'
Hayya 'alal
'alas soloh
Hayya 'alas
mavsum boyicha


yuklab olish