我正在创建一个需要数据库的应用程序.我使用sqlite数据库浏览器创建它,这意味着我创建的应用程序,将我创建的数据库导入手机.
我创建的应用程序要求用户将数据输入数据库.升级数据库时,我希望保留用户输入的数据.
我的数据库帮助程序代码如下:
public class DatabaseHelper extends SQLiteOpenHelper {
//The Android's default system path of your application database.
private static String DB_PATH = "/data/data/test.test/databases/";
private static String DB_NAME = "TestDatabase";
private static final int DB_VERSION = 1;
private SQLiteDatabase myDatabase;
private final Context myContext;
/**
* # Constructor #
* Takes and keeps a reference of the passed context in order to access to the application assets and resources.
* @param context
*/
public DatabaseHelper(Context context) {
super(context, DB_NAME, null, …Run Code Online (Sandbox Code Playgroud) 我一直在尝试创建一个与地图相关的Android应用程序,但我意识到我的应用程序的onLocationChanged尚未调用,因此地图始终保持默认区域(美国).
我的代码:
public class MapMainActivity extends MapActivity
implements OnClickListener, LocationListener {
MapView mapView;
/** Called when the activity is first created. */
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.map_main);
//reference
mapView = (MapView)findViewById(R.id.map_view);
mapView.setBuiltInZoomControls(true);
this.findViewById(R.id.btn_satellite).setOnClickListener(this);
this.findViewById(R.id.btn_street).setOnClickListener(this);
}//onCreate
@Override
protected void onResume() {
super.onResume();
Toast.makeText(this, "GPS tracking started",
Toast.LENGTH_SHORT).show();
// Start location updates; 5s/5m
LocationManager locManager = (LocationManager)getSystemService(
Context.LOCATION_SERVICE);
locManager.requestLocationUpdates(LocationManager.GPS_PROVIDER,
5000, 0, this);
Criteria crit = new Criteria();
crit.setAccuracy(Criteria.ACCURACY_FINE);
String provider = locManager.getBestProvider(crit, true);
Location loc = locManager.getLastKnownLocation(provider);
}//onResume
@Override …Run Code Online (Sandbox Code Playgroud) 当用户第一次打开应用程序时,我想要一个弹出窗口.
如何检查/获取应用程序打开的次数?
请帮忙.非常感谢.
我正在尝试为我的自定义ExpandableListView调用notifyDataSetChanged.发生的事情是我的孩子列表,它显示所选文件夹(组列表)中的文件.点击孩子时,会询问是否删除文件.然后,删除后,ExpandableList将"刷新".但不知何故,我无法调用notifyDataSetChanged方法.
我的定制适配器:
public class customListAdapter extends BaseExpandableListAdapter {
// Sample data set. children[i] contains the children (String[]) for groups[i].
private File mapFolder = new File (Environment.getExternalStorageDirectory(),"/MLT/A");
private File recordFolder = new File (Environment.getExternalStorageDirectory(),"/MLT/B");
private File scribbleFolder = new File (Environment.getExternalStorageDirectory(),"/MLT/C");
private String[] groups = { "A", "B", "C" };
private String[][] children = { mapFolder.list(), recordFolder.list(), scribbleFolder.list() };
public Object getChild(int groupPosition, int childPosition) {
return children[groupPosition][childPosition];
}
public long getChildId(int groupPosition, int childPosition) {
return childPosition;
}
public int …Run Code Online (Sandbox Code Playgroud) 我正在尝试将录制的音频文件保存在我想要的文件夹中,而不是默认文件夹.但不知怎的,我没有这样做.
我的代码:
Intent recordIntent = new Intent(MediaStore.Audio.Media.RECORD_SOUND_ACTION);
Uri mUri = Uri.fromFile(new File(Environment.getExternalStorageDirectory(), "/Record/sound_"+ String.valueOf(System.currentTimeMillis()) + ".amr"));
recordIntent.putExtra(android.provider.MediaStore.EXTRA_OUTPUT, mUri);
startActivityForResult(recordIntent, RESULT_OK);
Run Code Online (Sandbox Code Playgroud)
它确实调用了录音机应用程序.并且当我按下停止按钮时,它返回到我的应用程序并出现一个吐司,说它已保存.但是,而不是保存在我的记录文件夹中,它保存在默认文件夹中.
我意识到logcat中有错误信息:
01-29 01:34:23.900: E/ActivityThread(10824): Activity com.sec.android.app.voicerecorder.VoiceRecorderMainActivity has leaked ServiceConnection com.sec.android.app.voicerecorder.util.VRUtil$ServiceBinder@405ce7c8 that was originally bound here
Run Code Online (Sandbox Code Playgroud)
当我调用相机应用程序时,我不确定代码是否有效.