Warning: file_get_contents(/data/phpspider/zhask/data//catemap/7/sqlite/3.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Android rValues TestUtilities函数(如果需要) ContentValues testWeatherValues=TestUtilities.createWeatherValues(locationRowId); //将ContentValues插入数据库并获取行ID long weatherRowId=db.insert(WeatherContract.WeatherEntry.TABLE_NAME,null,testWeatherValues); assertTrue(“错误:插入测试天气值失败”,weatherRowId!=-1); //查询数据库并接收返回的游标 游标weatherCursor=db.query( WeatherContract.WeatherEntry.TABLE_名称, 无效的 无效的 无效的 无效的 无效的 无效的 ); //将光标移动到有效的数据库行 assertTrue(“错误:测试天气查询未返回任何行”,weatherCursor.moveToFirst()); //使用原始内容值验证结果游标中的数据 //(您可以使用TestUtilities中的validateCurrentRecord函数来验证 //查询(如果您愿意) TestUtilities.validateCurrentRecord(“验证测试天气值失败”, weatherCursor、TestWeatherValue); assertFalse(“错误:从位置查询返回的行数超过一行”,weatherCursor.moveToNext()); //最后,关闭光标和数据库 weatherCursor.close(); db.close(); } /* 学生:这是testWeatherTable测验的辅助方法。你可以移动你的手臂 从testLocationTable到此处的代码,以便您可以从两者调用此代码 testWeatherTable和testLocationTable。 */ 公共长插入位置(){ //第一步:获取对可写数据库的引用 SQLiteDatabase db=newweatherdbhelper(this.mContext).getWritableDatabase(); //将ContentValues插入数据库并获取行ID ContentValues testValues=TestUtilities.createNorthPoleLocationValues(); long rowId=db.insert(WeatherContract.LocationEntry.TABLE_NAME,null,testValues); assertTrue(“错误:插入测试位置值失败”,rowId!=-1); //查询数据库并接收返回的游标 光标位置Cursor=db.query( WeatherContract.LocationEntry.TABLE_名称, 无效的 无效的 无效的 无效的 无效的 无效的 ); //将光标移动到有效的数据库行 assertTrue(“错误:测试位置查询未返回任何行”,locationCursor.moveToFirst()); //使用原始内容值验证结果游标中的数据 //(您可以使用TestUtilities中的validateCurrentRecord函数来验证 //查询(如果您愿意) TestUtilities.validateCurrentRecord(“验证测试位置值失败”, 位置游标,测试值); assertFalse(“错误:从位置查询返回的行数超过一行”,locationCursor.moveToNext()); //最后,关闭光标和数据库 locationCursor.close(); db.close(); 返回rowId; //返回-1; } }_Android_Sqlite_Junit - Fatal编程技术网

Android rValues TestUtilities函数(如果需要) ContentValues testWeatherValues=TestUtilities.createWeatherValues(locationRowId); //将ContentValues插入数据库并获取行ID long weatherRowId=db.insert(WeatherContract.WeatherEntry.TABLE_NAME,null,testWeatherValues); assertTrue(“错误:插入测试天气值失败”,weatherRowId!=-1); //查询数据库并接收返回的游标 游标weatherCursor=db.query( WeatherContract.WeatherEntry.TABLE_名称, 无效的 无效的 无效的 无效的 无效的 无效的 ); //将光标移动到有效的数据库行 assertTrue(“错误:测试天气查询未返回任何行”,weatherCursor.moveToFirst()); //使用原始内容值验证结果游标中的数据 //(您可以使用TestUtilities中的validateCurrentRecord函数来验证 //查询(如果您愿意) TestUtilities.validateCurrentRecord(“验证测试天气值失败”, weatherCursor、TestWeatherValue); assertFalse(“错误:从位置查询返回的行数超过一行”,weatherCursor.moveToNext()); //最后,关闭光标和数据库 weatherCursor.close(); db.close(); } /* 学生:这是testWeatherTable测验的辅助方法。你可以移动你的手臂 从testLocationTable到此处的代码,以便您可以从两者调用此代码 testWeatherTable和testLocationTable。 */ 公共长插入位置(){ //第一步:获取对可写数据库的引用 SQLiteDatabase db=newweatherdbhelper(this.mContext).getWritableDatabase(); //将ContentValues插入数据库并获取行ID ContentValues testValues=TestUtilities.createNorthPoleLocationValues(); long rowId=db.insert(WeatherContract.LocationEntry.TABLE_NAME,null,testValues); assertTrue(“错误:插入测试位置值失败”,rowId!=-1); //查询数据库并接收返回的游标 光标位置Cursor=db.query( WeatherContract.LocationEntry.TABLE_名称, 无效的 无效的 无效的 无效的 无效的 无效的 ); //将光标移动到有效的数据库行 assertTrue(“错误:测试位置查询未返回任何行”,locationCursor.moveToFirst()); //使用原始内容值验证结果游标中的数据 //(您可以使用TestUtilities中的validateCurrentRecord函数来验证 //查询(如果您愿意) TestUtilities.validateCurrentRecord(“验证测试位置值失败”, 位置游标,测试值); assertFalse(“错误:从位置查询返回的行数超过一行”,locationCursor.moveToNext()); //最后,关闭光标和数据库 locationCursor.close(); db.close(); 返回rowId; //返回-1; } }

Android rValues TestUtilities函数(如果需要) ContentValues testWeatherValues=TestUtilities.createWeatherValues(locationRowId); //将ContentValues插入数据库并获取行ID long weatherRowId=db.insert(WeatherContract.WeatherEntry.TABLE_NAME,null,testWeatherValues); assertTrue(“错误:插入测试天气值失败”,weatherRowId!=-1); //查询数据库并接收返回的游标 游标weatherCursor=db.query( WeatherContract.WeatherEntry.TABLE_名称, 无效的 无效的 无效的 无效的 无效的 无效的 ); //将光标移动到有效的数据库行 assertTrue(“错误:测试天气查询未返回任何行”,weatherCursor.moveToFirst()); //使用原始内容值验证结果游标中的数据 //(您可以使用TestUtilities中的validateCurrentRecord函数来验证 //查询(如果您愿意) TestUtilities.validateCurrentRecord(“验证测试天气值失败”, weatherCursor、TestWeatherValue); assertFalse(“错误:从位置查询返回的行数超过一行”,weatherCursor.moveToNext()); //最后,关闭光标和数据库 weatherCursor.close(); db.close(); } /* 学生:这是testWeatherTable测验的辅助方法。你可以移动你的手臂 从testLocationTable到此处的代码,以便您可以从两者调用此代码 testWeatherTable和testLocationTable。 */ 公共长插入位置(){ //第一步:获取对可写数据库的引用 SQLiteDatabase db=newweatherdbhelper(this.mContext).getWritableDatabase(); //将ContentValues插入数据库并获取行ID ContentValues testValues=TestUtilities.createNorthPoleLocationValues(); long rowId=db.insert(WeatherContract.LocationEntry.TABLE_NAME,null,testValues); assertTrue(“错误:插入测试位置值失败”,rowId!=-1); //查询数据库并接收返回的游标 光标位置Cursor=db.query( WeatherContract.LocationEntry.TABLE_名称, 无效的 无效的 无效的 无效的 无效的 无效的 ); //将光标移动到有效的数据库行 assertTrue(“错误:测试位置查询未返回任何行”,locationCursor.moveToFirst()); //使用原始内容值验证结果游标中的数据 //(您可以使用TestUtilities中的validateCurrentRecord函数来验证 //查询(如果您愿意) TestUtilities.validateCurrentRecord(“验证测试位置值失败”, 位置游标,测试值); assertFalse(“错误:从位置查询返回的行数超过一行”,locationCursor.moveToNext()); //最后,关闭光标和数据库 locationCursor.close(); db.close(); 返回rowId; //返回-1; } },android,sqlite,junit,Android,Sqlite,Junit,这里给我的错误是 03-03 16:34:41.531 2010-2026/com.example.android.sunshine.app E/SQLiteLog:(1)靠近“name”:语法错误03-03 16:34:41.533 2010-2026/com.example.android.sunshine.app E/SQLiteDatabase:错误 插入城市名称=北极坐标=64.7488坐标=147.353 位置设置=99705 android.database.sqlite.SQLi

这里给我的错误是

03-03 16:34:41.531 2010-2026/com.example.android.sunshine.app E/SQLiteLog:(1)靠近“name”:语法错误03-03 16:34:41.533 2010-2026/com.example.android.sunshine.app E/SQLiteDatabase:错误 插入城市名称=北极坐标=64.7488坐标=147.353 位置设置=99705 android.database.sqlite.SQLiteException:靠近“name”:语法错误 (代码1):,编译时:插入位置(城市) 名称、坐标纬度、坐标长度、位置设置)值(?,,?,?) 在 android.database.sqlite.SQLiteConnection.nativePrepareStatement(本机 (方法) 在 android.database.sqlite.SQLiteConnection.acquirePreparedStatement(SQLiteConnection.java:889) 在 android.database.sqlite.SQLiteConnection.prepare(SQLiteConnection.java:500) 在 android.database.sqlite.SQLiteSession.prepare(SQLiteSession.java:588) 位于android.database.sqlite.SQLiteProgram.(SQLiteProgram.java:58) 在 android.database.sqlite.SQLiteStatement.(SQLiteStatement.java:31) 在 android.database.sqlite.SQLiteDatabase.insertWithOnConflict(SQLiteDatabase.java:1469) 在 android.database.sqlite.SQLiteDatabase.insert(SQLiteDatabase.java:1341) 在 com.example.android.sunshine.app.data.TestDb.insertLocation(TestDb.java:179) 在 com.example.android.sunshine.app.data.TestDb.testLocationTable(TestDb.java:115) 位于java.lang.reflect.Method.invoke(本机方法) 位于java.lang.reflect.Method.invoke(Method.java:372) 位于junit.framework.TestCase.runTest(TestCase.java:168) 位于junit.framework.TestCase.runBare(TestCase.java
 /*
 * Copyright (C) 2014 The Android Open Source Project
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *      http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */
package com.example.android.sunshine.app.data;

import android.provider.BaseColumns;
import android.text.format.Time;

/**
 * Defines table and column names for the weather database.
 */
public class WeatherContract {

    // To make it easy to query for the exact date, we normalize all dates that go into
    // the database to the start of the the Julian day at UTC.
    public static long normalizeDate(long startDate) {
        // normalize the start date to the beginning of the (UTC) day
        Time time = new Time();
        time.set(startDate);
        int julianDay = Time.getJulianDay(startDate, time.gmtoff);
        return time.setJulianDay(julianDay);
    }

    /*
        Inner class that defines the table contents of the location table
        Students: This is where you will add the strings.  (Similar to what has been
        done for WeatherEntry)
     */
    public static final class LocationEntry implements BaseColumns {
        public static final String TABLE_NAME = "location";

        public static final String COLUMN_LOCATION_SETTING = "location_setting";

        public static final String COLUMN_CITY_NAME = "city name";

        public static final String COLUMN_COORD_LAT = "coord_lat";

        public static final String COLUMN_COORD_LONG = "coord_long";

    }

    /* Inner class that defines the table contents of the weather table */
    public static final class WeatherEntry implements BaseColumns {

        public static final String TABLE_NAME = "weather";

        // Column with the foreign key into the location table.
        public static final String COLUMN_LOC_KEY = "location_id";
        // Date, stored as long in milliseconds since the epoch
        public static final String COLUMN_DATE = "date";
        // Weather id as returned by API, to identify the icon to be used
        public static final String COLUMN_WEATHER_ID = "weather_id";

        // Short description and long description of the weather, as provided by API.
        // e.g "clear" vs "sky is clear".
        public static final String COLUMN_SHORT_DESC = "short_desc";

        // Min and max temperatures for the day (stored as floats)
        public static final String COLUMN_MIN_TEMP = "min";
        public static final String COLUMN_MAX_TEMP = "max";

        // Humidity is stored as a float representing percentage
        public static final String COLUMN_HUMIDITY = "humidity";

        // Humidity is stored as a float representing percentage
        public static final String COLUMN_PRESSURE = "pressure";

        // Windspeed is stored as a float representing windspeed  mph
        public static final String COLUMN_WIND_SPEED = "wind";

        // Degrees are meteorological degrees (e.g, 0 is north, 180 is south).  Stored as floats.
        public static final String COLUMN_DEGREES = "degrees";
    }
}
    /*
 * Copyright (C) 2014 The Android Open Source Project
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *      http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */
package com.example.android.sunshine.app.data;

import android.content.Context;
import android.database.sqlite.SQLiteDatabase;
import android.database.sqlite.SQLiteOpenHelper;

import com.example.android.sunshine.app.data.WeatherContract.LocationEntry;
import com.example.android.sunshine.app.data.WeatherContract.WeatherEntry;

/**
 * Manages a local database for weather data.
 */
public class WeatherDbHelper extends SQLiteOpenHelper {

    // If you change the database schema, you must increment the database version.
    private static final int DATABASE_VERSION = 3;

    static final String DATABASE_NAME = "weather.db";

    public WeatherDbHelper(Context context) {
        super(context, DATABASE_NAME, null, DATABASE_VERSION);
    }

    @Override
    public void onCreate(SQLiteDatabase sqLiteDatabase) {
        final String SQL_CREATE_LOCATION_TABLE = "CREATE TABLE " + LocationEntry.TABLE_NAME + " (" +
                LocationEntry._ID + " INTEGER PRIMARY KEY, " +

                LocationEntry.COLUMN_LOCATION_SETTING + " TEXT UNIQUE NOT NULL, " +
                LocationEntry.COLUMN_CITY_NAME + " TEXT NOT NULL, " +
                LocationEntry.COLUMN_COORD_LAT + " REAL NOT NULL, " +
                LocationEntry.COLUMN_COORD_LONG + " REAL NOT NULL, " +


                // Inserting a new data with the same location setting will not update the table
                // and is ignored. No row ID will be returned
                "UNIQUE (" + LocationEntry.COLUMN_LOCATION_SETTING + ") ON CONFLICT IGNORE );";

        final String SQL_CREATE_WEATHER_TABLE = "CREATE TABLE " + WeatherEntry.TABLE_NAME + " (" +
                // Why AutoIncrement here, and not above?
                // Unique keys will be auto-generated in either case.  But for weather
                // forecasting, it's reasonable to assume the user will want information
                // for a certain date and all dates *following*, so the forecast data
                // should be sorted accordingly.
                WeatherEntry._ID + " INTEGER PRIMARY KEY AUTOINCREMENT," +

                // the ID of the location entry associated with this weather data
                WeatherEntry.COLUMN_LOC_KEY + " INTEGER NOT NULL, " +
                WeatherEntry.COLUMN_DATE + " INTEGER NOT NULL, " +
                WeatherEntry.COLUMN_SHORT_DESC + " TEXT NOT NULL, " +
                WeatherEntry.COLUMN_WEATHER_ID + " INTEGER NOT NULL," +

                WeatherEntry.COLUMN_MIN_TEMP + " REAL NOT NULL, " +
                WeatherEntry.COLUMN_MAX_TEMP + " REAL NOT NULL, " +

                WeatherEntry.COLUMN_HUMIDITY + " REAL NOT NULL, " +
                WeatherEntry.COLUMN_PRESSURE + " REAL NOT NULL, " +
                WeatherEntry.COLUMN_WIND_SPEED + " REAL NOT NULL, " +
                WeatherEntry.COLUMN_DEGREES + " REAL NOT NULL, " +

                // Set up the location column as a foreign key to location table.
                " FOREIGN KEY (" + WeatherEntry.COLUMN_LOC_KEY + ") REFERENCES " +
                LocationEntry.TABLE_NAME + " (" + LocationEntry._ID + "), " +

                // To assure the application have just one weather entry per day
                // per location, it's created a UNIQUE constraint with REPLACE strategy
                " UNIQUE (" + WeatherEntry.COLUMN_DATE + ", " +
                WeatherEntry.COLUMN_LOC_KEY + ") ON CONFLICT REPLACE);";

        sqLiteDatabase.execSQL(SQL_CREATE_LOCATION_TABLE);
        sqLiteDatabase.execSQL(SQL_CREATE_WEATHER_TABLE);
    }

    @Override
    public void onUpgrade(SQLiteDatabase sqLiteDatabase, int oldVersion, int newVersion) {
        // This database is only a cache for online data, so its upgrade policy is
        // to simply to discard the data and start over
        // Note that this only fires if you change the version number for your database.
        // It does NOT depend on the version number for your application.
        // If you want to update the schema without wiping data, commenting out the next 2 lines
        // should be your top priority before modifying this method.
        sqLiteDatabase.execSQL("DROP TABLE IF EXISTS " + LocationEntry.TABLE_NAME);
        sqLiteDatabase.execSQL("DROP TABLE IF EXISTS " + WeatherEntry.TABLE_NAME);
        onCreate(sqLiteDatabase);
    }
}
/*
 * Copyright (C) 2014 The Android Open Source Project
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *      http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */
package com.example.android.sunshine.app.data;

import android.content.ContentValues;
import android.database.Cursor;
import android.database.sqlite.SQLiteDatabase;
import android.test.AndroidTestCase;

import java.util.HashSet;

public class TestDb extends AndroidTestCase {

    public static final String LOG_TAG = TestDb.class.getSimpleName();

    // Since we want each test to start with a clean slate
    void deleteTheDatabase() {
        mContext.deleteDatabase(WeatherDbHelper.DATABASE_NAME);
    }

    /*
        This function gets called before each test is executed to delete the database.  This makes
        sure that we always have a clean test.
     */
    public void setUp() {
        deleteTheDatabase();
    }

    /*
        Students: Uncomment this test once you've written the code to create the Location
        table.  Note that you will have to have chosen the same column names that I did in
        my solution for this test to compile, so if you haven't yet done that, this is
        a good time to change your column names to match mine.

        Note that this only tests that the Location table has the correct columns, since we
        give you the code for the weather table.  This test does not look at the
     */
    public void testCreateDb() throws Throwable {
        // build a HashSet of all of the table names we wish to look for
        // Note that there will be another table in the DB that stores the
        // Android metadata (db version information)
        final HashSet<String> tableNameHashSet = new HashSet<String>();
        tableNameHashSet.add(WeatherContract.LocationEntry.TABLE_NAME);
        tableNameHashSet.add(WeatherContract.WeatherEntry.TABLE_NAME);

        mContext.deleteDatabase(WeatherDbHelper.DATABASE_NAME);
        SQLiteDatabase db = new WeatherDbHelper(
                this.mContext).getWritableDatabase();
        assertEquals(true, db.isOpen());

        // have we created the tables we want?
        Cursor c = db.rawQuery("SELECT name FROM sqlite_master WHERE type='table'", null);

        assertTrue("Error: This means that the database has not been created correctly",
                c.moveToFirst());

        // verify that the tables have been created
        do {
            tableNameHashSet.remove(c.getString(0));
        } while( c.moveToNext() );

        // if this fails, it means that your database doesn't contain both the location entry
        // and weather entry tables
        assertTrue("Error: Your database was created without both the location entry and weather entry tables",
                tableNameHashSet.isEmpty());

        // now, do our tables contain the correct columns?
        c = db.rawQuery("PRAGMA table_info(" + WeatherContract.LocationEntry.TABLE_NAME + ")",
                null);

        assertTrue("Error: This means that we were unable to query the database for table information.",
                c.moveToFirst());

        // Build a HashSet of all of the column names we want to look for
        final HashSet<String> locationColumnHashSet = new HashSet<String>();
        locationColumnHashSet.add(WeatherContract.LocationEntry._ID);
        locationColumnHashSet.add(WeatherContract.LocationEntry.COLUMN_CITY_NAME);
        locationColumnHashSet.add(WeatherContract.LocationEntry.COLUMN_COORD_LAT);
        locationColumnHashSet.add(WeatherContract.LocationEntry.COLUMN_COORD_LONG);
        locationColumnHashSet.add(WeatherContract.LocationEntry.COLUMN_LOCATION_SETTING);

        int columnNameIndex = c.getColumnIndex("name");
        do {
            String columnName = c.getString(columnNameIndex);
            locationColumnHashSet.remove(columnName);
        } while(c.moveToNext());

        // if this fails, it means that your database doesn't contain all of the required location
        // entry columns
        assertTrue("Error: The database doesn't contain all of the required location entry columns",
                locationColumnHashSet.isEmpty());
        db.close();
    }

    /*
        Students:  Here is where you will build code to test that we can insert and query the
        location database.  We've done a lot of work for you.  You'll want to look in TestUtilities
        where you can uncomment out the "createNorthPoleLocationValues" function.  You can
        also make use of the ValidateCurrentRecord function from within TestUtilities.
    */
    public void testLocationTable() {
        long id = insertLocation();
    }

    /*
        Students:  Here is where you will build code to test that we can insert and query the
        database.  We've done a lot of work for you.  You'll want to look in TestUtilities
        where you can use the "createWeatherValues" function.  You can
        also make use of the validateCurrentRecord function from within TestUtilities.
     */
    public void testWeatherTable() {
        long locationRowId = insertLocation();

        // First step: Get reference to writable database
        SQLiteDatabase db = new WeatherDbHelper(this.mContext).getWritableDatabase();
        assertTrue("Error: failure to open the database for writing",db.isOpen());

        // Create ContentValues of what you want to insert
        // (you can use the createWeatherValues TestUtilities function if you wish)
        ContentValues testWeatherValues = TestUtilities.createWeatherValues(locationRowId);

        // Insert ContentValues into database and get a row ID back
        long weatherRowId = db.insert(WeatherContract.WeatherEntry.TABLE_NAME, null, testWeatherValues);
        assertTrue("Error: failure to insert test weather values", weatherRowId != -1);

        // Query the database and receive a Cursor back
        Cursor weatherCursor =  db.query(
                WeatherContract.WeatherEntry.TABLE_NAME,
                null,
                null,
                null,
                null,
                null,
                null
        );

        // Move the cursor to a valid database row
        assertTrue("Error: Test weather query returned no rows", weatherCursor.moveToFirst());

        // Validate data in resulting Cursor with the original ContentValues
        // (you can use the validateCurrentRecord function in TestUtilities to validate the
        // query if you like)
        TestUtilities.validateCurrentRecord("Verifying test weather values failed",
                weatherCursor, testWeatherValues);

        assertFalse("Error: mMore than one row returned from location query", weatherCursor.moveToNext());

        // Finally, close the cursor and database
        weatherCursor.close();
        db.close();
    }


    /*
        Students: This is a helper method for the testWeatherTable quiz. You can move your
        code from testLocationTable to here so that you can call this code from both
        testWeatherTable and testLocationTable.
     */
    public long insertLocation() {

        // First step: Get reference to writable database
        SQLiteDatabase db = new WeatherDbHelper(this.mContext).getWritableDatabase();

        // Insert ContentValues into database and get a row ID back
        ContentValues testValues = TestUtilities.createNorthPoleLocationValues();
        long rowId = db.insert(WeatherContract.LocationEntry.TABLE_NAME, null, testValues);
        assertTrue("Error: failure to insert test location values", rowId != -1);

        // Query the database and receive a Cursor back
        Cursor locationCursor =  db.query(
                WeatherContract.LocationEntry.TABLE_NAME,
                null,
                null,
                null,
                null,
                null,
                null
        );

        // Move the cursor to a valid database row
        assertTrue("Error: Test location query returned no rows", locationCursor.moveToFirst());

        // Validate data in resulting Cursor with the original ContentValues
        // (you can use the validateCurrentRecord function in TestUtilities to validate the
        // query if you like)
        TestUtilities.validateCurrentRecord("Verifying test location values failed",
                locationCursor, testValues);

        assertFalse("Error: mMore than one row returned from location query", locationCursor.moveToNext());

        // Finally, close the cursor and database
        locationCursor.close();
        db.close();
        return rowId;
        //return -1;
    }
}
   public static final String COLUMN_CITY_NAME = "city name";
   public static final String COLUMN_CITY_NAME = "city_name";