[英]simple password protect your android application
我是android開發的新手。 我想創建一個簡單的受密碼保護的應用程序,該應用程序在啟動時要求輸入密碼。 登錄對話框應該只要求輸入密碼或退出。 而已! 如果密碼輸入正確,則應啟動應用程序,否則應要求用戶再次輸入密碼,並給出退出選項。
歡迎從頭開始提供所有詳細信息的答案。
跟着這些步驟 :
您可以將密碼保存在數據庫中或SharedPreferences內部。
引用Internet以使用數據庫或SharedPreferences。
例如,SharedPreferences:
SharedPreferences mySharedPreferences;
SharedPreferences.Editor myEditor;
mySharedPreferences = getSharedPreferences("usernamepassworddetails", MODE_PRIVATE);
myEditor = mySharedPreferences.edit();
myEditor.commit();
//In this code you can add the details
myEditor.putInt("username", imageWidth);
myEditor.putInt("password", imageHeight);
myEditor.putInt("position", currentPosition);
myEditor.commit();
//獲取數據的代碼
mySharedPreferences.getInt("username", 0)
mySharedPreferences.getInt("password", 0)
有關數據庫的代碼,請參見以下鏈接: http : //www.vogella.de/articles/AndroidSQLite/article.html
讓我知道這是否有幫助。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.