I want to get Bookmark through the Android app.

Asked 2 years ago, Updated 2 years ago, 99 views

I am studying the Android application by referring to the following documents.
http://tutorial.jp/prog/android/andman.pdf

I wrote the code referring to p.112 "Examples of Applications Obtaining 6.6.5 Bookmarks" and got the following error.How can I solve this problem?Thank you.
Enter a description of the image here

The code for java is as follows

package com.example.shimadzutsunehiko.getbookmmrk;

import android.app.Activity;
import android.app.Fragment;
import android.database.Cursor;
import android.os.Bundle;
import android.provider.Browser;
import android.support.design.widget.FloatingActionButton;
import android.support.design.widget.Snackbar;
import android.support.v4.app.FragmentActivity;
import android.support.v7.app.AppCompatActivity;
import android.support.v7.widget.Toolbar;
import android.view.View;
import android.view.Menu;
import android.view.MenuItem;
import android.widget.ArrayAdapter;
import android.widget.ListView;

public class MainActivity extensions Activity {

    @ Override
    protected void onCreate (Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);
        getBookmark();
    }

    public void getBookmark(){
        Cursorc=getContentResolver().query(
                Browser.BOOKMARKS_URI,
                new String [ ] {
                        Browser.BookmarkColumns.URL,
                        Browser.BookmarkColumns.TITLE
                },
                null, null, null);
        if(c.moveToFirst()){
            intitle=c.getColumnIndexOrThrow(
                    Browser.BookmarkColumns.TITLE);
            intiurl=c.getColumnIndexOrThrow(
                    Browser.BookmarkColumns.URL);
            ArrayAdapter adapter=
                    new ArrayAdapter(this,
                            android.R.layout.simple_list_item_1);
            finalListView listView=(ListView) findViewById (R.id.listview);
            do{
                adapter.add("["+c.getString(itle)+"]"+c.getString(iurl)));
            }while(c.moveToNext());
            listView.setAdapter(adapter);
        }
        c.close();
    }

    @ Override
    public boolean onCreateOptionsMenu(Menu){
        // Inflate the menu; this add items to the action bar if it is present.
        getMenuInflater().inflate(R.menu.menu_main, menu);
        return true;
    }

    @ Override
    public boolean onOptionsItemSelected(MenuItem){
        // Handle action bar item clicks here. The action bar will
        // automatically handle clicks on the Home/Up button, solo
        // as you specify a parent activity in AndroidManifest.xml.
        int id = item.getItemId();

        // no inspection SimplifiableIfStatement
        if(id==R.id.action_settings){
            return true;
        }

        return super.onOptionsItemSelected(item);
    }
}

The development environment is androidstudio.

android

2022-09-30 21:02

1 Answers

The field appears to have been removed from API level 23.

Develop at a lower API level or
I guess I have no choice but to write a replacement code.

http://developer.android.com/sdk/api_diff/23/changes.html


2022-09-30 21:02

If you have any answers or tips


© 2024 OneMinuteCode. All rights reserved.