Android :: Extended ContentProvider Not Behaving Properly

Aug 25, 2010

I'm trying to implement a ContentProvider wrapped around an SQLite database.

I've followed the tutorial here in building my ContentProvider:tutorial

I want to test what I have; so I'm attempting to instantiate my new ContentProvider, retrieve a Cursor from the query handler, and attach it to my CursorAdapter. Currently, I'm doing this in the onCreate of my Activity (I know this is bad practice, I'm just testing, I will move it to a service eventually).

CODE:.....

When I launch my application, the onCreate method of my extended ContentProvider gets executed. The database helper object gets created, the database gets created, and the onCreate method returns true. However, when I try to use my ContentProvider (with the code above), in the open() method the database helper object gets created, but getWritableDatabase() returns null. Also, when I call open(), the reference to getContext() is null.

Note: everything else seems to be working fine. When I call query, it hits my query handler, recognizes the Uri and attempts to run my query code (which obviously blows up because the database object is null).

Here are my extended ContentProvider and database helper:

CODE:........

I'm wondering if I should somehow be referencing whatever instance of MessagesProvider was created when I launched the application, instead of declaring a new one (p) and using it?

I updated the onCreate code in my Activity to the following, but managedQuery returned null:

CODE:......................

Android :: Extended ContentProvider not behaving properly


Android :: V2.1 Behaving Differently On Different Phones

Sep 26, 2010

We have an application that runs fine on my Samsung Moment but crashes on load on my HTC Hero, both running 2.1. I thought Android was Android.

View 1 Replies View Related

Android :: Transparency On Views Behaving Differently In 1.5

Apr 25, 2009

I have a lot of Views where I have set a background image on the top LinearLayout and then I have nested a new linear layout below with a background that is semi-transparent. This works great in 1.1, but in 1.5 the transparency is just disregarded and this breaks my app as the text on top is now unreadable.

Is this a bug or a feature? Is there a better way of doing this? Very grateful for any tips!

Code example:

CODE:....................

View 13 Replies View Related

Android :: Market Behaving Strangely Today

May 31, 2010

Firstly I'm not able to download anything from the markets... the status just shows 'Starting download' and it just sticks there. This has been happening for a day or so, and I have two devices on different networks, so it must be the market and not me.

Also, I have some apps installed which the market doesn't recognize, it just shows the option to download as normal.

View 5 Replies View Related

Android :: ListView Focus Behaving Different When Using MinSdkVersion-3

Mar 15, 2010

A few days ago I was trying to fix this issue: I have a header (three ImageButton's) and a ListView. If I use the dpad, pressing DOWN to focus the ListView, the ListView shows as selected the seventh or eighth row, not the first one.

What I need to do is that the first element of the ListView get the focus (or selection) when I use the dpad, from another screen component, but instead, the seventh or eighth is selected.

I had minSdkVersion=3 in my manifest. When I changed it to minSdkVersion=4 it worked as expected (first row selected). Don't know why, but there is a difference between both.

View 6 Replies View Related

Android : Ant Vs Eclipse / Build Methods Are Behaving Differently?

Mar 15, 2010

The Eclipse build for my 1.6 application project is succeeding and the Ant build is failing. I'm looking for help on why they aren't behaving the same way.

We are developing on Mac OSX 10.5.8 with Eclipse 3.5 against SDK 1.6 + Google APIs. There are no setting changes in Eclipse, either at workspace or project level. Similarly, our ant is also a vanilla- flavored unmodified installation of 1.7.1. JDK is 1.5.0_22. The CLASSPATH environment variable is not set. JAVA_HOME is /Library/Java/ Home

The application was initially created by a team member using the Eclipse plugins. The application references two jar files, one of which has a dependency on javax.xml.bind.annotation.XmlSeeAlso, which is not defined anywhere in our code or in android.jar. The other jar file has an explicit dependency on android.jar. I generated the Ant build file using android update.

The Eclipse project builds an apk and runs the application in the emulator. I think this is incorrect behavior.

The Android project fails to build. I think this is correct behavior. MyClass.java:98: cannot access javax.xml.bind.annotation.XmlSeeAlso[javac] file javax/xml/bind/annotation/XmlSeeAlso.class not found

Any ideas as to why the two build methods are behaving differently? I would expect them both to fail.

View 5 Replies View Related

Android :: Dumped XML Layout File Padding Positions Not Behaving Correctly

Dec 30, 2009

I've been trying to figure out how to make some sense of a dumped XML layout, and it's progressing 'pretty good'. The only thing I'm currently unsure about is the following:

When I use the command:

aapt dump xmltree <pathofapk> <pathofxmlfile>

I get the following result:

CODE:.............

That's all good, but what I'm trying to figure out is how to convert the following code into the XML layout file:

CODE:.................

Converting those values to decimal would result in:

CODE:.................

All good, but I've been trying to figure out what the (type 0x5 means). With all other types, the result is defined in the Android.util.TypedValue.class file

Decompiling that, gives the following result for 0x5:

CODE:...............

Makes sense, in a way. But, I need to know what kind of value it is, so looking down, I find the following value:

CODE:.............

But, when I try to use 2561mm and 1025mm (It's a tad much anyway, 25cm is.. larger than my screen), The whole screen is filled with the 'parent LinearLayout'.

View 3 Replies View Related

Android :: How To Know Caller Of ContentProvider?

Dec 17, 2009

We are developing a ContentProvider which is supposed to serve for specified packages. So we want to get the caller package name. Is there any way to achieve that?

View 2 Replies View Related

Android : Querying The SMS ContentProvider

Apr 6, 2010

I currently register a content observer on the following URI "content://sms/" to listen out for incoming and outgoing messages being sent.

This seems to work ok and I have also tried deleting from the sms database but I can only delete an entire thread from the following URI "content://sms/conversations/"

Here is the code I use for that

CODE:............

However I want to be able to get the recipricant and the message text from the SMS Content Provider, can anyone tell me how to do this?

And also how to delete one message instead of an entire thread?

View 2 Replies View Related

Android : When Is A ContentProvider Really Created

Aug 14, 2010

I have a ContentProvider which is declared in the Manifest, when is it really created ? When the application is launched but before launching the first activity ? When the first query/update/insert is done ? When ?

View 1 Replies View Related

Android : Add A New ContentProvider To Contacts

Jun 29, 2009

I want to add an extra field to the phonebook on android. The field contains a new contact method and when clicked it should start my own application/intent. I have created my own content provider that stores the information. I want to add this contentProvider to the phonebook in the same way organizations and email are added to the phone book. So how do i do this? I tried adding a new contact method but the field KIND needs an integer input which seems to be predefined to some specific methods (EMAIL, IM, ADDRESS etc)

So do i need to add a new type of KIND or can I link my contentProvider to the phone book so that it shows up as an extra field in the phone book?

View 2 Replies View Related

Android : ContentProvider Designing In My App

Aug 24, 2010

All the example codes, tutorials or video I see, there is always one ContentProvider per SQL Table with the SQLiteOpenHelper extension defined as a private static class... Is it some sort of standard design...to have one ContentProvider per SQL Table? Or I can define one generic ContentProvider and use its instance for ever update? Is there some issue with that? Could anyone please help as my application has like 5-6 tables.

View 12 Replies View Related

Android : Close The DB In A ContentProvider

Aug 18, 2009

Maybe it's an easy question, but I've tried to understand why all the content providers seem not to close the DB that they use. In the NotePadProvider example (in other providers is similar), it's used a Helper to manage the DB (that extends of SQLiteOpenHelper).

This helper has a method to close the DB (http://developer.android.com/ reference/android/database/sqlite/SQLiteOpenHelper.html#close%28%29), but in all the providers that I have seen (even in the example), this method is never used.

For example, in the query method of the NotPadProvider we use the helper to open a DB

CODE:...........

The mOpenHelper is create in the "onCreate()" method, but there is no reference to a mOpenHelper.close() in all the provider (maybe because there is no "close()" method in ContentProvider).

Do we need to close the SQLiteOpenHelper object? When we use it inside a ContentProvider, where is the right place to close it?

View 5 Replies View Related

Android : Getting Object From ContentProvider

Aug 12, 2010

I have a custom class, which represents my data-structure. This custom class is in a normal Java-library, which is included in both projects. I have one Project with a ContentProvider which provides this data to Activities of other Projects. And an other Project with an Activity, where I want to handle this data in objects of this custom class.

How can I get this data to the Activity? The Cursor [1] only supports primitive Types.

[1] http://developer.android.com/reference/android/database/Cursor.html

View 5 Replies View Related

Android :: Test If ContentProvider Exists

Jun 1, 2010

How can I test if there's a ContentProvider for a Uri ?

I'm currently doing a query on it and checking for a null cursor, but that generates an error in the system log each time, which I don't like to do.

View 3 Replies View Related

Android :: AutoCompleteTextView Working With ContentProvider

Jun 20, 2010

I have an AutoCompleteTextView working with a ContentProvider that correctly pulls known information from a database when the user is typing and presents it. However, I would also like to support the automatic hints/word choice list you get when using apps like the Messaging app. I haven't figured out how to get that thin bar of word choices to appear. Can some one clue me in on how to use that in combination with my existing ContentProvider?

View 2 Replies View Related

Android :: Get Email Address Using ContentProvider

Aug 27, 2009

I would like to get the contact name, contact number, and contact email id using the contentProvider. Can any one please guide me to achieve this.

View 3 Replies View Related

Android : What Is The Lifetime Of A ContentProvider - After OnCreate

Aug 17, 2010

What is the lifetime of a ContentProvider in Android? After onCreate() is invoked, will the ContentProvider persist unconditionally for the lifetime of the process?

My ContentProvider manages a list of records, but only 1 is designated "active" and will be accessed by different applications a lot. I was wondering if it's safe to cache the index of this active record in memory as a member of my ContentProvider to speed up lookup.

View 1 Replies View Related

Android : Which Thread Runs ContentProvider

Aug 16, 2010

If I call to a ContentProvider from a Activity, which thread is ContentProvider running in?

E.g. What happens if the Activity is killed and a query is executing in the ContentProvider? Say that you have a slow network query f.ex.

View 1 Replies View Related

Android : ContentProvider Fails On Insert

Jul 30, 2010

I am brand new to developing for android and have hit something of a stumbling block that I cant seem to get around.

Using the NotePad example, I have created my own ContentProvider to serve up data from a database that I will eventually host on a webserver. But that is lightyears away from where I am right now.

Just testing my ContentProvider has caused a bit of a headache that I cant solve. For some reason, when the provider calls SQLiteDatabase db = mOpenHelper.getWritableDatabase(); I get a null pointer exception.

Code Follows:

CODE:............

Stack Trace

CODE:......................

View 1 Replies View Related

Android : ProgressDialog From Within ContentProvider Class

Dec 5, 2009

I have been stuck at a place , strange, I have a content provider class i.e class extends ContentProvider, I want to know about the method to show the dialog to the user when upgrading / creating a content provider or database from within content provider, I tried many ways for it, but nothing seems to be working, Can anybody here direct me to the reference or can tell me the way I can show progress dialog box from within contentprodiver.

View 11 Replies View Related

Android : Instantiate My ContentProvider - When My Apk Is Started

Dec 15, 2009

In my application, I have created a ContentProvider. Is there a way for me to instantiate this ContentProvider when my apk is started? RIght now, the ContentProvider only instantiate when some one does a query.

View 2 Replies View Related

Android : Notify CursorAdapter Changes In My Own ContentProvider

Dec 2, 2009

I am writing my own ContentProvider for my own application. And there is a ListView with a CursorAdapter pulling data from my Content Provider. My question is when there is a data change in my ContentProvider, how can I notify my CursorAdatper to requery the data and then have the ListView updated?

View 2 Replies View Related

Android : ContentProvider.query - Is Not Being Called

Oct 11, 2009

I have been playing around with the SearchableDictionary sample application trying to understand it.

I set a breakpoint in DictionaryProvider.query() and verified that it's going in there when I turn on search for this application (settings > search > searchable items > Searchable Dictionary).

Then I tried modifying the AndroidManifest.xml file, changing the launch activity to .WordActivity --

CODE:..............

I also had to change WordActivity so it would startup (albeit not be useful) --

CODE:...............

My expectation was that when I ran it and typed something in the QSB (search box on the main android page), it would still trigger the breakpoint. It's like it doesn't even recognize that the app should be part of the search anymore. I try moving the manifest changes back and it goes back to working.

The thing that led me down this path was that I am trying to write my own ContentProvider, and I can't get the QSB to call my query method. So what gives with this sample code here? What is preventing (or enabling) query() to be called from the QSB?

View 3 Replies View Related

Android : Multiple Tables In One ContentProvider

Oct 6, 2009

I want to operate on multiple tables. I searched a lot but everywhere I could find is single table with one content provider.

How can I use multiple tables under one content provider? How can I get result from two/three tables ?

Can I provide my own SQL select query from multiple tables in ContentProvider?

Can anybody give me any example or link where I can get idea?

View 4 Replies View Related

Android : Accessing Contentprovider From A Pojo

Jul 1, 2010

How can i access a content provider from a pojo? all ways i found depends on that my class extends Activity :-( api version 3

View 3 Replies View Related

Android :: Possible To Retrieve Data From Two Tables Via ContentProvider Way?

Apr 5, 2009

How to retrieve data from two tables via the ContentProvider way? I.E. the database of Calendar application, include many tables including Events and Deleted, and some others. I want to retrive records in Events table, whose _sync_id field is also in Deleted table. Usually, we write a SQL sentence like: select (all fields in Events) from Events as e, Deleted as d where e._sync_id = d._sync_id or select * rom Events as e where e._sync_id in select _sync_id from Deleted etc. But, how can I accomplish it in the ContentProvider way? I saw ContentProvider.query take a Uri as the first parameter, but pity that I don't know how to build one that could fulfill my purpose.

View 2 Replies View Related

Android :: ContentProvider Queries - Contacts And The SDK Docs

May 15, 2009

A couple of questions. First thing I was wondering is where to log bugs in the docs. The ContentProvider query() docs are missing selectionArgs in the example code. It also uses the deprecated addId instead of ContentUris.withAppendedId().

With regards to the selection options - how exactly can these handle? I've seen a couple of places where a something + "='" + somevalue "'" is used, but I'm specifically wondering if it can handle IN clauses or if there's some form of or statement I can use to check for a variety of values in a particular column rather than just the one.

Last question is about the Contacts PERSON_ID and how long-lived that is. It is guaranteed to never change (though may be removed obviously). Well not truly guaranteed but will only cycle after it runs out of unused integers. Or may they change value as contacts are removed?

View 5 Replies View Related

Android :: Start A Service From The ContentProvider.onCreate()?

Feb 7, 2010

My application after an update needs to fill its ContentProvider with some data found on the server.
I found that starting a service from the ContentProvider.onCreate() method works but I'm not sure if it is a good idea or if it works randomly.

I don't know the initialization of an application in android. Are the services always already available before the content provider is created?

View 2 Replies View Related

Android :: Storing A Bitmap Into A ContentProvider From A BroadcastReciever

Aug 17, 2010

I'm working on an app that, upon instillation of certain apps will send a message to them to register with a content provider. It all works fine, the strings are stored, but I can't get the byte[] blob (a bitmap .png file) to convert properly from within onRecieve() in the broadcastreciever.

CODE:.................

I hijack the context so that I can get a hold on the image from the getAppIcon() call (You extend this class which is an abstract class extending BroadcastReceiver) i.e.

CODE:......

But my understanding of the context is limited and I think this is what is causing it to be stored incorrectly.

I've also tried getting the bitmap from the resources when onRecieve() is called and that doesn't work either.

View 1 Replies View Related







Copyrights 2005-15 www.BigResource.com, All rights reserved