Android Open Source - The-Weather-App Locations Provider






From Project

Back to project page The-Weather-App.

License

The source code is released under:

Apache License

If you think the Android project The-Weather-App listed in this page is inappropriate, such as containing malicious code/tools or violating the copyright, please email info at java2s dot com, thanks.

Java Source Code

package com.sachinshinde.theweatherapp.db;
/*from  w ww .j av  a 2 s  .c  o m*/
import android.content.ContentProvider;
import android.content.ContentValues;
import android.database.Cursor;
import android.net.Uri;

public class LocationsProvider extends ContentProvider {

    // All URIs share these parts
    public static final String AUTHORITY = "com.sachinshinde.theweatherapp.provider";
    public static final String SCHEME = "content://";

    // URIs
    // Used for all locations
    public static final String LOCATIONS = SCHEME + AUTHORITY + "/locations";
    public static final Uri URI_LOCATIONS = Uri.parse(LOCATIONS);
    // Used for a single location, just add the id to the end
    public static final String LOCATION_BASE = LOCATIONS + "/";

    public LocationsProvider() {
    }

    @Override
    public int delete(Uri uri, String selection, String[] selectionArgs) {
        // Implement this to handle requests to delete one or more rows.
        throw new UnsupportedOperationException("Not yet implemented");
    }

    @Override
    public String getType(Uri uri) {
        // TODO: Implement this to handle requests for the MIME type of the data
        // at the given URI.
        throw new UnsupportedOperationException("Not yet implemented");
    }

    @Override
    public Uri insert(Uri uri, ContentValues values) {
        // TODO: Implement this to handle requests to insert a new row.
        throw new UnsupportedOperationException("Not yet implemented");
    }

    @Override
    public boolean onCreate() {
        return true;
    }

    @Override
    public Cursor query(Uri uri, String[] projection, String selection,
                        String[] selectionArgs, String sortOrder) {
        Cursor result = null;
        if (URI_LOCATIONS.equals(uri)) {
            result = LocationDBHandler
                    .getInstance(getContext())
                    .getReadableDatabase()
                    .query(Locations.TABLE_NAME, Locations.FIELDS, null, null, null,
                            null, null, null);
            result.setNotificationUri(getContext().getContentResolver(), URI_LOCATIONS);
        }
        else if (uri.toString().startsWith(LOCATION_BASE)) {
            final long id = Long.parseLong(uri.getLastPathSegment());
            result = LocationDBHandler
                    .getInstance(getContext())
                    .getReadableDatabase()
                    .query(Locations.TABLE_NAME, Locations.FIELDS,
                            Locations.KEY_ID + " IS ?",
                            new String[] { String.valueOf(id) }, null, null,
                            null, null);
            result.setNotificationUri(getContext().getContentResolver(), URI_LOCATIONS);
        }
        else {
            throw new UnsupportedOperationException("Not yet implemented");
        }

        return result;
    }

    @Override
    public int update(Uri uri, ContentValues values, String selection,
                      String[] selectionArgs) {
        // TODO: Implement this to handle requests to update one or more rows.
        throw new UnsupportedOperationException("Not yet implemented");
    }
}




Java Source Code List

com.sachinshinde.theweatherapp.ApplicationTest.java
com.sachinshinde.theweatherapp.db.LocationDBHandler.java
com.sachinshinde.theweatherapp.db.LocationsProvider.java
com.sachinshinde.theweatherapp.db.Locations.java
com.sachinshinde.theweatherapp.libs.SwipeDismissRecyclerViewTouchListener.java
com.sachinshinde.theweatherapp.libs.SwipeDismissTouchListener.java
com.sachinshinde.theweatherapp.ui.main.activities.AboutClass.java
com.sachinshinde.theweatherapp.ui.main.activities.AllCities.java
com.sachinshinde.theweatherapp.ui.main.activities.BaseActivity.java
com.sachinshinde.theweatherapp.ui.main.activities.LocationDetailActivity.java
com.sachinshinde.theweatherapp.ui.main.activities.LocationListActivity.java
com.sachinshinde.theweatherapp.ui.main.fragments.LocationDetailFragment.java
com.sachinshinde.theweatherapp.ui.main.fragments.LocationListFragment.java
com.sachinshinde.theweatherapp.ui.main.fragments.NavigationDrawerFragment.java
com.sachinshinde.theweatherapp.ui.main.views.DrawShadowFrameLayout.java
com.sachinshinde.theweatherapp.ui.main.views.MultiSwipeRefreshLayout.java
com.sachinshinde.theweatherapp.ui.main.views.ScrimInsetsFrameLayout.java
com.sachinshinde.theweatherapp.ui.main.views.ScrimInsetsScrollView.java
com.sachinshinde.theweatherapp.utils.ChangeLog.java
com.sachinshinde.theweatherapp.utils.Constant.java
com.sachinshinde.theweatherapp.utils.LUtils.java
com.sachinshinde.theweatherapp.utils.LogUtils.java
com.sachinshinde.theweatherapp.utils.PrefUtils.java
com.sachinshinde.theweatherapp.utils.UIUtils.java
com.sachinshinde.theweatherapp.utils.Utilities.java