当我试图将数据插入我的sqlite数据库时,我收到一个logcat错误"未知数据库logindata:,同时编译:".错误消息听起来很直接,但我可以找到问题所在.在我的数据库类或插入数据的活动中.
错误信息:
unknown database logindata: , while compiling: create table if not exists logindata.db (_id integer primary key autoincrement,username text not null,password text not null);
Run Code Online (Sandbox Code Playgroud)
数据库:
public class LoginDB extends SQLiteOpenHelper {
//Table attributes
public static final String DATABASE_NAME = "logindata.db";
public static final int DATABASE_VERSION = 1;
public static final String TABLE_NAME_INFOTABLE = "credentials";
// Data attributes
public static final String COLUMN_NAME_USERNAME = "username";
public static final String COLUMN_NAME_PASSWORD = "password";
private SQLiteOpenHelper DBHelper;
private SQLiteDatabase db;
public LoginDB(Context …
Run Code Online (Sandbox Code Playgroud) 我正在尝试使用 Base64 加密 editText 字符串,wnich 将保存在共享首选项中,但是一旦字符串被编码并保存,我的 .xml 文件就是空白的。我是一名新手程序员,对加密非常陌生,所以我迷路了,不知道如何正确分析我的代码以确定可能非常简单的问题。我收到了一些建议,但没有任何内容清楚地表明问题出在哪里,为什么它不起作用,以及如何解决它。我怀疑我的加密方法,但不确定在哪里。对于试图保护用户名和密码条目的编码人员来说,这必须是一项常见任务。本教程用于此加密项目单击此处
这是用于编码、加密和保存 EditText 字符串的类:
public void onClick(View arg0) {
user=rName.getText().toString().trim();
pass=rPwd.getText().toString().trim();
if(arg0==regBttn){
if((user.length()!=0))
{
if((pass.length()!=0))
{
sp=getSharedPreferences("AccessApp",MODE_WORLD_WRITEABLE);
Editor myEditor=sp.edit();
byte[] key = { 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 0, 1, 2, 3, 4, 5, 6 };
try {
String encryptedUser = encrypt(user, key);
myEditor.putString("USERNAME_KEY", encryptedUser);
}
catch (Exception e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
try {
String encryptedPass = encrypt(pass, key);
myEditor.putString("PASSWORD_KEY", encryptedPass);
} …
Run Code Online (Sandbox Code Playgroud) base64 android exception encryption-symmetric sharedpreferences