如何从数据库中读取变量

时间:2015-04-08 04:08:00

标签: java android mysql database variables

在这个android编码中,我声明了内联的变量路径。 我想从数据库中检索变量,因为IPTV源每周都在变化

这是代码:

private String path = "rtmp://live.dltv.cn:1935/live/live11";

private VideoView mVideoView;
ProgressBar progressBar = null;
 public menu1(){}

@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container,
                         Bundle savedInstanceState) {

    View rootView = inflater.inflate(R.layout.menu1_layout, container, false);
    mVideoView = (VideoView) rootView.findViewById(R.id.surface_view);
    progressBar = (ProgressBar) rootView.findViewById(R.id.progressBar);

    if (!io.vov.vitamio.LibsChecker.checkVitamioLibs(getActivity())){
        Log.d("TAG", "Could not load");
    }
    if (path.equals("")) {
        // Tell the user to provide a media file URL/path.
        Toast.makeText(getActivity(), "Please edit VideoViewDemo Activity, and set path" + " variable to your media file URL/path", Toast.LENGTH_LONG).show();

  return;


  } else {
        /*
         * Alternatively,for streaming media you can use
         * mVideoView.setVideoURI(Uri.parse(URLstring));
         */
        mVideoView.setVideoPath(path);
        mVideoView.setMediaController(new MediaController(getActivity()));
        mVideoView.setVideoChroma(MediaPlayer.VIDEOCHROMA_RGB565);
        mVideoView.requestFocus();

        progressBar.setVisibility(View.VISIBLE);
        mVideoView.setOnPreparedListener(new MediaPlayer.OnPreparedListener() {
            @Override
            public void onPrepared(MediaPlayer mediaPlayer) {
                // optional need Vitamio 4.0
                progressBar.setVisibility(View.GONE);
                mediaPlayer.setPlaybackSpeed(1.0f);

            }
        });
    }

1 个答案:

答案 0 :(得分:0)

尝试将路径保存为SharedPreference,让用户在其中保存路径并检索首选项。